forked from Tescalus/Pendulum-Hubs-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KillbotV2.lua
1502 lines (1394 loc) · 49.9 KB
/
KillbotV2.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
loadstring(game:HttpGet("https://raw.githubusercontent.com/Tescalus/Pendulum-Hubs-Source/main/Reanimation.lua"))()
--// SHORTCUTS \\--
local SCRIPTUTIL = game:GetObjects("rbxassetid://5276526474")[1]
local function linear(t, b, c, d)
return c * t / d + b
end
local function inBack(t, b, c, d, s)
if not s then s = 1.70158 end
t = t / d
return c * t * t * ((s + 1) * t - s) + b
end
local function outBack(t, b, c, d, s)
if not s then s = 1.70158 end
t = t / d - 1
return c * (t * t * ((s + 1) * t + s) + 1) + b
end
local Vector3Sequence,Vector3SequenceKeypoint = {},{}
Vector3SequenceKeypoint.new = function(time,value,envelope)
--bad argument #2 to 'new' (number expected, got Vector3)
assert(typeof(time)=='number',"bad argument #1 to 'new' (number expected, got "..typeof(time))
assert(typeof(value)=='Vector3',"bad argument #2 to 'new' (Vector3 expected, got "..typeof(value))
return {Time=time,Value=value,Envelope=envelope}
end
Vector3Sequence.new = function(...)
local tuple={...}
if(#tuple==2)then
return Vector3Sequence.new{Vector3SequenceKeypoint.new(0,tuple[1]),Vector3SequenceKeypoint.new(1,tuple[2])}
else
local thing = tuple[1]
if(typeof(thing)=='Vector3')then
return Vector3Sequence.new(thing,thing)
elseif(typeof(thing)=='table')then
assert(#thing>=2,"Vector3Sequence: requires at least 2 keypoints")
local last;
for i,v in next, thing do
assert(v.Value and v.Time and typeof(v.Value)=='Vector3',"expected 'Vector3SequenceKeypoint' at index "..i)
if(not last or v.Time>last)then
last=v.Time
else
error("Vector3Sequence: all keypoints must be ordered by time")
end
end
return setmetatable({
Keypoints=thing;
},{__index=Vector3Sequence})
else
return error("table of Vector3SequenceKeypoints expected.")
end
end
end
local CFrameSequence,CFrameSequenceKeypoint = {},{}
CFrameSequenceKeypoint.new = function(time,value,envelope)
--bad argument #2 to 'new' (number expected, got CFrame)
assert(typeof(time)=='number',"bad argument #1 to 'new' (number expected, got "..typeof(time))
assert(typeof(value)=='CFrame',"bad argument #2 to 'new' (CFrame expected, got "..typeof(value))
return {Time=time,Value=value,Envelope=envelope}
end
CFrameSequence.new = function(...)
local tuple={...}
if(#tuple==2)then
return CFrameSequence.new{CFrameSequenceKeypoint.new(0,tuple[1]),CFrameSequenceKeypoint.new(1,tuple[2])}
else
local thing = tuple[1]
if(typeof(thing)=='CFrame')then
return CFrameSequence.new(thing,thing)
elseif(typeof(thing)=='table')then
assert(#thing>=2,"CFrameSequence: requires at least 2 keypoints")
local last;
for i,v in next, thing do
assert(v.Value and v.Time and typeof(v.Value)=='CFrame',"expected 'CFrameSequenceKeypoint' at index "..i)
if(not last or v.Time>last)then
last=v.Time
else
error("CFrameSequence: all keypoints must be ordered by time")
end
end
return setmetatable({
Keypoints=thing;
},{__index=CFrameSequence})
else
return error("table of CFrameSequenceKeypoints expected.")
end
end
end
local RNG = (function()
local RNG = Random.new();
return function(min,max,int)
return int and RNG:NextInteger(min,max) or RNG:NextNumber(min,max)
end;
end)();
local S = setmetatable({},{__index = function(s,i) return game:service(i) end})
local CF = {
N=CFrame.new;
A=CFrame.Angles;
fEA=CFrame.fromEulerAnglesXYZ;
}
local C3 = {
N=Color3.new;
RGB=Color3.fromRGB;
HSV=function(...)local data={...}if(typeof(data)=='Color3')then return Color3.toHSV(...)else return Color3.fromHSV(...)end;end;
}
local V3 = {
N=Vector3.new;
FNI=Vector3.FromNormalId;
A=Vector3.FromAxis;
}
local M = {
C=math.cos;
R=math.rad;
S=math.sin;
T=math.tan;
AT=math.atan;
AT2=math.atan2;
AS=math.asin;
AC=math.acos;
A=math.abs;
F=math.floor;
CE=math.ceil;
P=math.pi;
RNG=RNG;
H=math.huge;
RRNG=function(...) return math.rad(RNG(...)) end
}
local R3 = Region3.new
local De = S.Debris
local WS = workspace
local Lght = S.Lighting
local RepS = S.ReplicatedStorage
local IN = Instance.new
local Plrs = S.Players
--// INITIALIZATION \\--
local Plr = Plrs.LocalPlayer
local Char = game.Workspace.non
local Hum = Char:FindFirstChildOfClass'Humanoid'
assert(Hum and Hum.RigType==Enum.HumanoidRigType.R6,"You need to have a valid Humanoid instance! (Exising and R6)")
local Head = Char.Head
local RArm = Char["Right Arm"]
local LArm = Char["Left Arm"]
local RLeg = Char["Right Leg"]
local LLeg = Char["Left Leg"]
local Torso= Char.Torso
local Root = Char.HumanoidRootPart
local NeutralAnims = true
local Attack = false
local legAnims = true
local Mouse = Plr:GetMouse()
local EffectFolder=Instance.new("Folder")
EffectFolder.Name='Effects'
EffectFolder.Parent=Char
local FXFolder = SCRIPTUTIL:WaitForChild'Effects'
FXFolder.Parent=nil
local ExplosionDeb = SCRIPTUTIL:WaitForChild'ExplosionDebris'
ExplosionDeb.Parent=nil
local GibParticles = SCRIPTUTIL:WaitForChild'gibBlood'
GibParticles.Parent=nil
local Movement = 8
local Sine = 0;
local Change = 1;
local wsVal = 8
local crushedHead = SCRIPTUTIL:WaitForChild'CrushedHead'
crushedHead.Parent=nil
local BloodParticles = IN("Attachment")
SCRIPTUTIL:WaitForChild'Mist'.Parent=BloodParticles
--// INSTANCE CREATORS \\--
local baseSound = IN("Sound")
function Sound(parent,id,pitch,volume,looped,effect,autoPlay)
local Sound = baseSound:Clone()
Sound.SoundId = "rbxassetid://".. tostring(id or 0)
Sound.Pitch = pitch or 1
Sound.Volume = volume or 1
Sound.Looped = looped or false
if(autoPlay)then
coroutine.wrap(function()
repeat wait() until Sound.IsLoaded
Sound.Playing = autoPlay or false
end)()
end
if(not looped and effect)then
Sound.Stopped:connect(function()
Sound.Volume = 0
Sound:destroy()
end)
elseif(effect)then
warn("Sound can't be looped and a sound effect!")
end
Sound.Parent =parent or workspace
return Sound
end
function Part(parent,color,material,size,cframe,anchored,cancollide)
local part = IN("Part")
part[typeof(color) == 'BrickColor' and 'BrickColor' or 'Color'] = color or C3.N(0,0,0)
part.Material = material or Enum.Material.SmoothPlastic
part.TopSurface,part.BottomSurface=10,10
part.Size = size or V3.N(1,1,1)
part.CFrame = cframe or CF.N(0,0,0)
part.CanCollide = cancollide or false
part.Anchored = anchored or false
part.Parent = parent
return part
end
function Weld(part0,part1,c0,c1)
local weld = IN("Weld")
weld.Part0 = part0
weld.Part1 = part1
weld.C0 = c0 or CF.N()
weld.C1 = c1 or CF.N()
weld.Parent = part0
return weld
end
function Mesh(parent,meshtype,meshid,textid,scale,offset)
local part = IN("SpecialMesh")
part.MeshId = meshid or ""
part.TextureId = textid or ""
part.Scale = scale or V3.N(1,1,1)
part.Offset = offset or V3.N(0,0,0)
part.MeshType = meshtype or Enum.MeshType.Sphere
part.Parent = parent
return part
end
function SoundPart(id,pitch,volume,looped,effect,autoPlay,cf)
local soundPart = Part(EffectFolder,C3.N(1,1,1),Enum.Material.SmoothPlastic,V3.N(.05,.05,.05),cf,true,false)
soundPart.Transparency=1
local Sound = IN("Sound")
Sound.SoundId = "rbxassetid://".. tostring(id or 0)
Sound.Pitch = pitch or 1
Sound.Volume = volume or 1
Sound.Looped = looped or false
if(autoPlay)then
coroutine.wrap(function()
repeat wait() until Sound.IsLoaded
Sound.Playing = autoPlay or false
end)()
end
if(not looped and effect)then
Sound.Stopped:connect(function()
Sound.Volume = 0
soundPart:destroy()
end)
elseif(effect)then
warn("Sound can't be looped and a sound effect!")
end
Sound.Parent = soundPart
return Sound
end
function Joint(name,part0,part1,c0,c1,type)
local joint = IN(type or "Motor6D")
joint.Part0 = part0
joint.Part1 = part1
joint.C0 = c0 or CF.N()
joint.C1 = c1 or CF.N()
joint.Parent=part0
joint.Name=name or part0.." to "..part1.." "..joint.ClassName
return joint
end
function Animate(joint,c0,alpha,style,dir)
if(style=='Lerp')then
joint.C0 = joint.C0:lerp(c0,alpha)
else
local info = TweenInfo.new(alpha or 1,style or Enum.EasingStyle.Linear,dir or Enum.EasingDirection.Out,0,false,0)
local tween = S.TweenService:Create(joint,info,{C0=c0})
tween:Play();
return tween;
end
end
function NewInstance(instance,parent,properties)if(properties.Parent)then properties.Parent=parent end;local new = IN(instance)if(properties)then for prop,val in next, properties do pcall(function() new[prop]=val end)end;end;new.Parent=parent;return new;end
function GetAdjacentParts(part)
local function createLargerHitbox(part)
local n = 0.2
local clone = part:Clone()
clone.Transparency = .8
clone.BrickColor = BrickColor.Red()
clone.Size = clone.Size + Vector3.new(n, n, n)
clone.Name = "hitbox"
clone.CFrame = part.CFrame
clone.Anchored=true
clone.CanCollide=true
if (clone:IsA("WedgePart")) then
clone.Size = clone.Size + Vector3.new(0, n, n)
clone.CFrame = part.CFrame * CFrame.new(0, n / 2, -n /2)
end
if (clone:IsA("CornerWedgePart")) then
clone.Size = clone.Size + Vector3.new(n, n, n)
clone.CFrame = part.CFrame * CFrame.new(-n / 2, n / 2, n / 2)
end
clone.Parent = part
return clone
end
local hitbox = createLargerHitbox(part)
local touchingParts = hitbox:getTouchingParts()
hitbox:Destroy()
return (function()
local adjacent={}
for _,v in next, touchingParts do if(v~=part)then table.insert(adjacent,v)end;end
return adjacent;
end)()
end
--// CUSTOMIZABLE VARIABLES \\--
local Gren = SCRIPTUTIL:WaitForChild'Grenade'
local ShakeFactor = 2
local DamageColor = BrickColor.new'Really red';
local MusicData = {Parent=Torso,ID=4466439348;Pitch=.9;Volume=2;}
local God = false
local WalkSpeed = 25
local Music = Sound(MusicData.Parent,MusicData.ID,MusicData.Pitch,MusicData.Volume,true,false,true)
Music.Name = 'Music'
local Morph = SCRIPTUTIL:WaitForChild'Morph'
Morph.Head:Destroy()
local Highlights=Morph:WaitForChild'Right Arm':WaitForChild'Highlights'
for _,v in next, Char:children() do
if(Morph:FindFirstChild(v.Name))then
local part = Morph[v.Name]
part.Parent=Char
part:SetPrimaryPartCFrame(v.CFrame)
for _,c in next, part:GetDescendants() do
if(c:IsA'BasePart' and c~=part.PrimaryPart)then
c.Massless=true
c.Anchored=false
local j = Weld(v,c,CFrame.new(),c.CFrame:inverse()*v.CFrame)
c.CanCollide=false
end
end
part.PrimaryPart:destroy()
end
end
--// JOINTS \\--
local RJ = Joint("RootJoint",Root,Torso,CF.N(),CF.N())
local NK = Joint("Neck",Torso,Head,CF.N(0,1.5,0),CF.N())
local LS = Joint("Left Shoulder",Torso,LArm,CF.N(-1.5,.5,0),CF.N(0,.5,0))
local RS = Joint("Right Shoulder",Torso,RArm,CF.N(1.5,.5,0),CF.N(0,.5,0))
local LH = Joint("Left Hip",Torso,LLeg,CF.N(-.5,-2,0),CF.N(0,0,0))
local RH = Joint("Right Hip",Torso,RLeg,CF.N(.5,-2,0),CF.N(0,0,0))
local LSC0 = LS.C0
local RSC0 = RS.C0
local NKC0 = NK.C0
local LHC0 = LH.C0
local RHC0 = RH.C0
local RJC0 = RJ.C0
--// Artificial HB \\--
local ArtificialHB = IN("BindableEvent", SCRIPTUTIL)
ArtificialHB.Name = "Heartbeat"
SCRIPTUTIL:WaitForChild("Heartbeat")
local tf = 0
local allowframeloss = false
local tossremainder = false
local lastframe = tick()
local frame = 1/60
ArtificialHB:Fire()
game:GetService("RunService").Heartbeat:connect(function(s, p)
tf = tf + s
if tf >= frame then
if allowframeloss then
SCRIPTUTIL.Heartbeat:Fire()
lastframe = tick()
else
for i = 1, math.floor(tf / frame) do
ArtificialHB:Fire()
end
lastframe = tick()
end
if tossremainder then
tf = 0
else
tf = tf - frame * math.floor(tf / frame)
end
end
end)
function swait(num)
if num == 0 or num == nil then
ArtificialHB.Event:wait()
else
for i = 0, num do
ArtificialHB.Event:wait()
end
end
end
--// STOP ANIMATIONS \\--
for _,v in next, Hum:GetPlayingAnimationTracks() do
v:Stop();
end
pcall(game.Destroy,Char:FindFirstChild'Animate')
pcall(game.Destroy,Hum:FindFirstChild'Animator')
--// EFFECT FUNCTIONS \\--
local fromaxisangle = function(x, y, z) -- credit to phantom forces devs
if not y then
x, y, z = x.x, x.y, x.z
end
local m = (x * x + y * y + z * z) ^ 0.5
if m > 1.0E-5 then
local si = math.sin(m / 2) / m
return CFrame.new(0, 0, 0, si * x, si * y, si * z, math.cos(m / 2))
else
return CFrame.new()
end
end
function fakePhysics(elapsed,cframe,velocity,rotation,acceleration)
local pos = cframe.p
local matrix = cframe-pos
return fromaxisangle(elapsed*rotation)*matrix+pos+elapsed*velocity+elapsed*elapsed*acceleration
end
function CastRay(startPos,endPos,range,ignoreList)
local ray = Ray.new(startPos,(endPos-startPos).unit*range)
local part,pos,norm = workspace:FindPartOnRayWithIgnoreList(ray,ignoreList or {Char},false,true)
return part,pos,norm,(pos and (startPos-pos).magnitude)
end
function GetTorso(char)
return char:FindFirstChild'Torso' or char:FindFirstChild'UpperTorso' or char:FindFirstChild'LowerTorso' or char:FindFirstChild'HumanoidRootPart'
end
function Projectile(data)
local Size = data.Size or 1;
local Origin = data.Origin or CFrame.new();
local Velocity = data.Velocity or Vector3.new(0,100,0);
local Gravity = data.Gravity or workspace.Gravity;
local Color = data.Color or Color3.new(.7,0,0);
local Lifetime = data.Lifetime or 1;
local Material = data.Material or Enum.Material.Glass;
local ignore = data.Ignorelist or {Char};
local Init = data.Init;
local Update = data.Update;
local HitFunc = data.Hit;
local ShouldCollide = data.BeforeCollision;
local DeleteOnHit = not not data.DeleteOnHit;
local ProjectilePart = data.Projectile or nil;
local Look = data.AimAtPos or false;
local drop = ProjectilePart or Part(nil,Color,Material,Vector3.new(Size,Size,Size),Origin,true,false)
local StartTravel = tick()
local currCF = data.Origin
if(not ProjectilePart)then
Mesh(drop,Enum.MeshType.Sphere)
drop.Parent=EffectFolder
end
drop.Material = Material
drop.Color = Color
drop.CFrame=Origin
local object=setmetatable({Part=drop},{
__newindex=function(s,i,v)
if(i=='Gravity')then StartTravel = tick() data.Origin = currCF Origin=currCF data.Gravity = v Gravity=v
elseif(i=='Velocity')then StartTravel = tick() data.Origin = currCF Origin=currCF data.Velocity = v Velocity=v
elseif(i=='Lifetime')then data.Lifetime = v Lifetime=v
elseif(i=='Ignorelist')then data.Ignorelist = v ignore=v
elseif(i=='DeleteOnHit')then data.DeleteOnHit = v DeleteOnHit=v
else
pcall(function()
drop[i]=v
end)
end
end;
__index=data;
})
if(Init)then
Init(drop)
end
local startTick = tick();
coroutine.wrap(function()
while true do
local elapsed = tick()-startTick
local trElapsed = tick()-StartTravel
if(elapsed>Lifetime)then
drop:destroy();
break
end
local newCF = fakePhysics(trElapsed,Origin,Velocity,Vector3.new(),Vector3.new(0,-Gravity,0))
local nextCF = fakePhysics(trElapsed+.05,Origin,Velocity,Vector3.new(),Vector3.new(0,-Gravity,0))
local dist = (drop.Position-newCF.p).magnitude
local hit,pos,norm = CastRay(drop.Position,newCF.p,dist,ignore)
currCF=newCF
local doCollide = hit and (GetTorso(hit.Parent) or hit.CanCollide) and (not ShouldCollide or ShouldCollide(hit))
if(hit and not doCollide)then table.insert(ignore,hit) end
if(Look)then
drop.CFrame = CFrame.new(newCF.p,nextCF.p)
else
drop.CFrame = CFrame.new(newCF.p)
end
if(Update)then Update(drop,object,elapsed) end
if(doCollide)then
if(DeleteOnHit or not HitFunc)then drop:destroy() end
if(HitFunc)then if(HitFunc(hit,pos,norm,object,drop))then break end end
end
if(not drop.Parent)then
break
end
swait()
end
end)()
return object
end
function Chat(txt,Timer,Alpha,clr)
if(Head:FindFirstChild'Chattie' and Head.Chattie:FindFirstChild'Killchat')then
Head.Chattie.Killchat.Value=true
elseif(Head:FindFirstChild'Chattie')then
Head.Chattie:destroy()
end
local nig = V3.N(0,0,0)
local clr = (typeof(clr)=='BrickColor' and clr.Color or typeof(clr)=='Color3' and clr or C3.N(1,1,1))
local bg = NewInstance("BillboardGui",Head,{
Name='Chattie';
Adornee=Head;
LightInfluence=0;
Size=UDim2.new(4,0,2,0);
})
local dismiss = NewInstance("BoolValue",bg,{
Name='Killchat';
})
local text = NewInstance("TextLabel",bg,{
BackgroundTransparency=1;
Size=UDim2.new(1,0,1,0);
Font=Enum.Font.Fantasy;
Text=txt;
TextColor3=clr;
TextStrokeColor3=C3.N(0,0,0);
TextScaled=true;
TextTransparency=0;
TextStrokeTransparency=.5;
})
coroutine.wrap(function()
for i = 1, 0, -.02 do
bg.StudsOffsetWorldSpace=nig:lerp(nig+V3.N(0,3,0),outBack(1-i,0,1,1,6))
if(dismiss.Value)then break end
swait()
end
local start = tick()
nig=bg.StudsOffsetWorldSpace
repeat swait() until dismiss.Value or tick()-start>=timer
bg.Name='DismissingChat'
for i = 0, 1, .05 do
bg.StudsOffsetWorldSpace=nig:lerp(nig+V3.N(0,2,0),linear(i,0,1,1))
text.TextTransparency=i;
text.TextStrokeTransparency=.5+i/2;
swait()
end
bg:destroy()
end)()
end
function ShowDamage(pos,txt,timer,clr)
local nig = typeof(pos)=='Vector3' and CF.N(pos) or pos
local part = Part(EffectFolder,clr,Enum.Material.SmoothPlastic,V3.N(.05,.05,.05),nig,true,false)
part.Transparency=1
local bg = NewInstance("BillboardGui",part,{
Adornee=part;
LightInfluence=0;
Size=UDim2.new(2,0,1,0);
})
local text = NewInstance("TextLabel",bg,{
BackgroundTransparency=1;
Size=UDim2.new(1,0,1,0);
Font=Enum.Font.Fantasy;
Text=txt;
TextColor3=part.Color;
TextStrokeColor3=C3.N(0,0,0);
TextScaled=true;
TextTransparency=1;
TextStrokeTransparency=1;
})
coroutine.wrap(function()
for i = 1, 0, -.02 do
part.CFrame=nig:lerp(nig+V3.N(0,3,0),outBack(1-i,0,1,1,6))
text.TextTransparency=i;
text.TextTransparency=text.TextTransparency-.02;
text.TextStrokeTransparency=text.TextStrokeTransparency-.01;
swait()
end
local start = tick()
repeat swait() until tick()-start>=timer
local endRot=M.RNG(-25,25)
for i = 0, 1, .02 do
part.CFrame=(nig+V3.N(0,3,0)):lerp(nig+V3.N(0,-10,0),inBack(i,0,1,1,6))
text.TextTransparency=i;
text.TextTransparency=text.TextTransparency+.02;
text.TextStrokeTransparency=text.TextStrokeTransparency+.01;
swait()
end
part:destroy()
end)()
end
--[[function CamshakePlayer(p,settings)
local sh = SCRIPTUTIL:WaitForChild'CamShake':Clone()
local optionFolder = sh:WaitForChild'Options'
for _,v in next, optionFolder:children() do
if(settings[v.Name])then
v.Value=settings[v.Name]
end
end
local originVal;
if(typeof(settings.Origin)=='Vector3')then
originVal=IN("Vector3Value")
elseif(typeof(settings.Origin)=='CFrame')then
originVal=IN("CFrameValue")
elseif(typeof(settings.Origin)=='Instance')then
originVal=IN("ObjectValue")
end
if(originVal)then
originVal.Name = 'Origin'
originVal.Value = settings.Origin
originVal.Parent=optionFolder
end
local parent = p.Character or p:FindFirstChildOfClass'Backpack' or p:FindFirstChildOfClass'PlayerGui'
if(parent)then
local nig = sh:Clone();
nig.Parent=parent
nig.Disabled=false
S.Debris:AddItem(nig,(settings.Duration or 2)+1)
end
end
function Camshake(settings)
for _,p in next, game:service'Players':players() do
CamshakePlayer(p,settings)
end
end]]
function Tween(object,properties,time,style,dir,repeats,reverse,delay)
local info = TweenInfo.new(time or 1,style or Enum.EasingStyle.Linear,dir or Enum.EasingDirection.Out,repeats or 0,reverse or false,delay or 0)
local tween = S.TweenService:Create(object,info,properties)
tween:Play()
return tween;
end
local function numLerp(Start,Finish,Alpha)
return Start + (Finish- Start) * Alpha
end
function IsValidEnum(val,enum,def)
local enum = Enum[tostring(enum)]
local succ,err=pcall(function() return enum[val.Name] end)
if(not err)then
return val
else
return def
end
end
function IsValid(val,type,def)
if(typeof(type)=='string')then
return (typeof(val)==type and val or def)
elseif(typeof(type)=='table')then
for i,v in next, type do
if(typeof(val)==v)then
return val
end
end
end
return def
end
local FXInformation = {}
function EffectFunc(data)
--if(typeof(data)=='Instance' and data:IsA'ModuleScript')then data=require(data)end
assert(typeof(data)=='table',"Expected 'table' calling EffectFunc")
data.Parent=EffectFolder
if(data.BeamEffect)then
return Slash(data)
end
local Lifetime = data.Lifetime or 1;
local Color = data.Color or Color3.new(1,1,1)
local EndColor = data.EndColor
local Size = data.Size or Vector3.new(1,1,1)
local EndSize = data.EndSize
local Transparency = data.Transparency or 0
local EndTransparency = data.EndTransparency or 1
local Material = data.Material or Enum.Material.Neon;
local Part = typeof(data.RefPart)=='Instance' and data.RefPart or typeof(data.RefPart)=='string' and FXFolder:FindFirstChild(data.RefPart);
local CF = data.CFrame or CFrame.new(0,10,0)
local EndCF = data.EndCFrame or data.EndPos
local Mesh = data.MeshData or data.Mesh or {MeshType=Enum.MeshType.Brick}
local Rotation = data.Rotation or {0,0,0}
local UpdateCF = data.UpdateCFrame;
local Update = data.Update;
local CSQ,SSQ,TSQ,CFQ;
if(typeof(Color)=='BrickColor')then Color = Color.Color end
if(typeof(EndColor)=='BrickColor')then EndColor = EndColor.Color end
if(typeof(Color)=='ColorSequence')then
CSQ = Color
elseif(typeof(Color)=='Color3' and typeof(EndColor)=='Color3')then
CSQ = ColorSequence.new(Color,EndColor)
elseif(typeof(Color)=='Color3')then
CSQ = ColorSequence.new(Color)
else
CSQ = ColorSequence.new(Color3.new(1,1,1))
end
if(typeof(Size)=='table' and Size.Keypoints and typeof(Size.Keypoints[1].Value)=='Vector3')then
SSQ = Size
elseif(typeof(Size)=='Vector3' and typeof(EndSize)=='Vector3')then
SSQ = Vector3Sequence.new(Size,EndSize)
elseif(typeof(Size)=='Vector3')then
SSQ = Vector3Sequence.new(Size)
else
SSQ = Vector3Sequence.new(Vector3.new(1,1,1))
end
if(typeof(CF)=='table' and CF.Keypoints and typeof(CF.Keypoints[1].Value)=='CFrame')then
CFQ = CF
elseif(typeof(CF)=='CFrame' and typeof(EndCF)=='CFrame')then
CFQ = CFrameSequence.new(CF,EndCF)
elseif(typeof(CF)=='CFrame')then
CFQ = CFrameSequence.new(CF)
else
CFQ = CFrameSequence.new(CFrame.new(0,10,0))
end
if(typeof(Transparency)=='NumberSequence')then
TSQ = Transparency
elseif(typeof(Transparency)=='number' and typeof(EndTransparency)=='number')then
TSQ = NumberSequence.new(Transparency,EndTransparency)
elseif(typeof(Transparency)=='number')then
TSQ = NumberSequence.new(Transparency)
else
TSQ = NumberSequence.new(0,1)
end
local part,mesh;
if(not Part or not Part:IsA'BasePart')then
part = Instance.new("Part")
mesh = Instance.new("SpecialMesh",part)
else
part=Part:Clone();
mesh=part:FindFirstChildOfClass'DataModelMesh'
end
part.Color = CSQ.Keypoints[1].Value
part.Transparency = TSQ.Keypoints[1].Value
part.Size = (not mesh and SSQ.Keypoints[1].Value or Vector3.new(1,1,1))
part.Anchored = true
part.CanCollide = false
part.CFrame = CFQ.Keypoints[1].Value
part.Material = Material
part.Locked = true
part.Parent = EffectFolder
if(mesh)then
mesh.Scale = SSQ.Keypoints[1].Value
mesh.MeshType = Mesh.MeshType or Mesh.Type or Enum.MeshType.Brick
mesh.MeshId = Mesh.MeshId or Mesh.Id or ""
mesh.TextureId = Mesh.TextureId or Mesh.Texture or ""
end
game:service'Debris':AddItem(part,Lifetime*1.5)
table.insert(FXInformation,{
Part=part;
Mesh=mesh;
Lifetime=Lifetime;
Create=tick();
ColorSeq=CSQ;
SizeSeq=SSQ;
TranSeq=TSQ;
CFSeq=CFQ;
ColorPoint=CSQ.Keypoints[1];
SizePoint=SSQ.Keypoints[1];
TranPoint=TSQ.Keypoints[1];
CFPoint=CFQ.Keypoints[1];
Rotation=Rotation;
CurrRot=CFrame.new();
UpdateCF=(typeof(UpdateCF)=='function' and UpdateCF or nil);-- typeof(UpdateCF)=='Instance' and UpdateCF:IsA'ModuleScript' and require(UpdateCF) or
OnUpdate=(typeof(Update)=='function' and Update or nil) -- typeof(Update)=='Instance' and Update:IsA'ModuleScript' and require(Update) or
})
end
function GetKeyframe(sequence,currentTime,lifeTime)
local scale = currentTime/lifeTime
for i = 1,#sequence.Keypoints do
local keyframe = sequence.Keypoints[i]
local nframe = sequence.Keypoints[i+1]
if(not nframe or keyframe.Time>=scale and keyframe.Time<nframe.Time)then
return keyframe
end
end
return sequence.Keypoints[1];
end;
coroutine.wrap(function()
while true do
swait()
local queue={}
for i,dat in next, FXInformation do
local part,mesh,lifetime,created,csq,ssq,tsq,cfq,rot,ucf,upd =
dat.Part,
dat.Mesh,
dat.Lifetime,
dat.Create,
dat.ColorSeq,
dat.SizeSeq,
dat.TranSeq,
dat.CFSeq,
dat.Rotation,
dat.UpdateCF,
dat.OnUpdate;
local current = tick();
local elapsed = tick()-created
local currentcpoint = GetKeyframe(csq,elapsed,lifetime)
local currentspoint = GetKeyframe(ssq,elapsed,lifetime)
local currenttpoint = GetKeyframe(tsq,elapsed,lifetime)
local currentcfpoint = GetKeyframe(cfq,elapsed,lifetime)
local currentcolor = currentcpoint.Value
local currenttrans = currenttpoint.Value
local currentsize = currentspoint.Value
local currentcf = currentcfpoint.Value
if(currentcpoint~=dat.ColorPoint)then
Tween(part,{Color=currentcolor},(currentcpoint.Time-dat.ColorPoint.Time)*lifetime)
dat.ColorPoint=currentcpoint
end
if(currenttpoint~=dat.TranPoint)then
Tween(part,{Transparency=currenttrans},(currenttpoint.Time-dat.TranPoint.Time)*lifetime)
dat.TranPoint=currenttpoint
end
if(currentspoint~=dat.SizePoint)then
if(mesh)then
Tween(mesh,{Scale=currentsize},(currentspoint.Time-dat.SizePoint.Time)*lifetime)
else
Tween(part,{Size=currentsize},(currentspoint.Time-dat.SizePoint.Time)*lifetime)
end
dat.SizePoint=currentspoint
end
local newRot={0,0,0}
if(rot=='random')then
dat.CurrRot = CFrame.Angles(math.rad(Random.new():NextInteger(0,360)),math.rad(Random.new():NextInteger(0,360)),math.rad(Random.new():NextInteger(0,360)))
elseif(typeof(rot)=='table')then
dat.CurrRot = dat.CurrRot*CFrame.Angles(math.rad(rot[1]),math.rad(rot[2]),math.rad(rot[3]))
end
if(ucf and typeof(ucf)=='function')then
part.CFrame=ucf(dat)
elseif(#cfq.Keypoints==2)then
part.CFrame=cfq.Keypoints[1].Value:lerp(cfq.Keypoints[2].Value,elapsed/lifetime)*dat.CurrRot
else
if(currentcfpoint~=dat.CFPoint)then
Tween(part,{CFrame=currentcf},(currentcfpoint.Time-dat.CFPoint.Time)*lifetime)
dat.CFPoint=currentcfpoint
end
end
if(typeof(upd)=='function')then upd(dat) end
if(not part or not part.Parent)then
table.insert(queue,tostring(i))
end
if(elapsed>=lifetime)then
part:destroy()
end
end
for _,v in next, queue do FXInformation[tonumber(v)]=nil; end
end
end)()
function Slash(data) -- Credit to Kyu for the basic idea behind it
local Parent = IsValid(data.Parent,'Instance',workspace)
local Color = IsValid(data.Color,{'Color3','BrickColor'},Color3.new(1,1,1))
local Width = IsValid(data.Width,'number',2);
local EndWidth = IsValid(data.EndWidth,'number',0);
local Length = IsValid(data.Length,'number',1);
local EndLength = IsValid(data.EndLength,'number',Length*2);
local Curve = IsValid(data.Curve,"number",2);
local EndCurve = IsValid(data.EndCurve,"number",Curve*2);
local SCFrame = IsValid(data.CFrame,'CFrame',CFrame.new(0,10,0))
local Lifetime = IsValid(data.Lifetime,'number',.25)
local Offset = IsValid(data.Offset,'CFrame',CFrame.new())
local Style = IsValidEnum(IsValid(data.EasingStyle,'EnumItem',Enum.EasingStyle.Quad),Enum.EasingStyle,Enum.EasingStyle.Quad)
local Direction = IsValidEnum(IsValid(data.EasingDirection,'EnumItem',Enum.EasingDirection.Out),Enum.EasingDirection,Enum.EasingDirection.Out)
local Delay = IsValid(data.Delay,'number',0)
local BeamProperties = IsValid(data.BeamProps,'table',{})
local FadeAway = IsValid(data.Fades,'boolean',false)
local FadeStyle = IsValidEnum(IsValid(data.FadeStyle,'EnumItem',Enum.EasingStyle.Linear),Enum.EasingStyle,Enum.EasingStyle.Linear)
local FadeDir = IsValidEnum(IsValid(data.FadeDirection,'EnumItem',Enum.EasingDirection.Out),Enum.EasingDirection,Enum.EasingDirection.Out)
local CSQ;
local TSQ;
if(typeof(Color)=='ColorSequence')then
CSQ = Color
elseif(typeof(Color)=='Color3')then
CSQ = ColorSequence.new(Color)
elseif(typeof(Color)=='BrickColor')then
CSQ = ColorSequence.new(Color.Color)
else
CSQ = ColorSequence.new(Color3.new(1,1,1))
end
local P = Part(Parent,Color,Enum.Material.SmoothPlastic,Vector3.new(0,0,0),SCFrame,true,false)
P.Transparency = 1
local A0 = Instance.new("Attachment")
local A1 = Instance.new("Attachment")
A0.Position = Vector3.new(0,0,Length)
A1.Position = Vector3.new(0,0,-Length)
A0.Parent=P
A1.Parent=P
local Beam = Instance.new("Beam")
Beam.Attachment0=A0
Beam.Attachment1=A1
Beam.FaceCamera=true
Beam.LightInfluence=BeamProperties.LightInfluence or 0
Beam.LightEmission=BeamProperties.LightEmission or 1
for i,v in next, BeamProperties do
pcall(function() Beam[i]=v end)
end
Beam.Color = CSQ
Beam.CurveSize0 = Curve
Beam.CurveSize1 = -Curve
Beam.Width0=Width
Beam.Width1=Width
Beam.Parent=P
local ti = {Lifetime,Style,Direction,0,false,Delay}
Tween(P,{CFrame = SCFrame*Offset},unpack(ti))
Tween(Beam,{Width0=EndWidth,Width1=EndWidth,CurveSize0=EndCurve,CurveSize1=-EndCurve},unpack(ti))
Tween(A0,{Position=Vector3.new(0,0,EndLength)},unpack(ti))
Tween(A1,{Position=Vector3.new(0,0,-EndLength)},unpack(ti)).Completed:connect(function() P:destroy() end)
if(FadeAway)then
local part = Instance.new("Part")
part.Transparency = Beam.Transparency.Keypoints[1].Value or 0
Tween(part,{Transparency=1},Lifetime,FadeStyle,FadeDir,0,false,Delay)
repeat swait()
Beam.Transparency=NumberSequence.new(part.Transparency)
until not P.Parent
end
end
--// MISCELLANEOUS FUNCTIONS \\--
function GetTorso(char)
return char:FindFirstChild'Torso' or char:FindFirstChild'UpperTorso' or char:FindFirstChild'LowerTorso' or char:FindFirstChild'HumanoidRootPart'
end
function CastRay(startPos,endPos,range,ignoreList)
local ray = Ray.new(startPos,(endPos-startPos).unit*range)
local part,pos,norm = workspace:FindPartOnRayWithIgnoreList(ray,ignoreList or {Char},false,true)
return part,pos,norm,(pos and (startPos-pos).magnitude)
end
function getRegion(point,range,ignore)
return workspace:FindPartsInRegion3WithIgnoreList(R3(point-V3.N(1,1,1)*range/2,point+V3.N(1,1,1)*range/2),ignore,100)
end
--// DAMAGE, AOE, AND ATTACK FUNCTIONS \\--
function DealDamage(data)
local Who = data.Who;
local MinDam = data.MinimumDamage or 15;
local MaxDam = data.MaximumDamage or 30;
local MaxHP = data.MaxHP or 1e5;
local DamageIsPercentage = data.PercentageDamage or true
local DB = data.Debounce or .2;
local CritData = data.Crit or {}
local CritChance = CritData.Chance or 0;
local CritMultiplier = CritData.Multiplier or 1;
local OnHitFunc = data.OnHit
local DeathFunction = data.OnDeath
assert(Who,"Specify someone to damage!")
local Humanoid = Who:FindFirstChildOfClass'Humanoid'
local Critical = M.RNG(1,100,true) <= CritChance
local DoneDamage = M.RNG(MinDam,MaxDam,true) * (Critical and CritMultiplier or 1)
local canHit = true