forked from KadeTheExploiter/Krypton
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.luau
More file actions
1046 lines (820 loc) · 31.4 KB
/
Module.luau
File metadata and controls
1046 lines (820 loc) · 31.4 KB
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
-- \\ Krypton Reanimate, Author: @xyzkade/@kade4702. https://github.com/KadeTheExploiter/Krypton/ //
-- || GELATEK IS IN FACT THERE. | 1.7 After 5 months..
-- // Defining Variables: Settings
local Config = KryptonConfiguration or Configuration or {}
local function KryptonInit()
if not game.Loaded then
game.Loaded:Wait()
end
local WaitTime = Config.WaitTime or 0.25;
local Flinging = Config.Flinging
local Animations = Config.Animations
local AntiVoiding = Config.AntiVoiding
local SetCharacter = Config.SetCharacter
local NoBodyNearby = Config.NoBodyNearby
local ReturnOnDeath = Config.ReturnOnDeath
local ShowClientHats = Config.ShowClientHats
local FakeRigScale = Config.FakeRigScale or 1
local LimitHatsPerLimb = Config.LimitHatsPerLimb
local PresetFling = Config.PresetFling
local NoCollisions = Config.NoCollisions or Flinging
local SetSimulationRadius = Config.SetSimulationRadius
local OverlayFakeCharacter = Config.OverlayFakeCharacter
local DisableCharacterScripts = Config.DisableCharacterScripts
local TeleportOffsetRadius = Config.TeleportOffsetRadius or 12
local AccessoryFallbackDefaults = Config.AccessoryFallbackDefaults
local RigName = Config.RigName or "Evolution, it must've passed you by."
local DefaultHats = {
["Right Arm"] = {
{Texture = "14255544465", Mesh = "14255522247", Name = "RARM", Offset = CFrame.Angles(0, 0, math.rad(90))},
{Texture = "4645402630", Mesh = "3030546036", Name = "International Fedora", Offset = CFrame.Angles(math.rad(-90), 0, math.rad(90))}
},
["Left Arm"] = {
{Texture = "14255544465", Mesh = "14255522247", Name = "LARM", Offset = CFrame.Angles(0, 0, math.rad(90))},
{Texture = "3650139425", Mesh = "3030546036", Name = "International Fedora", Offset = CFrame.Angles(math.rad(-90), 0, math.rad(-90))}
},
["Right Leg"] = {
{Texture = "17374768001", Mesh = "17374767929", Name = "Accessory (RARM)", Offset = CFrame.Angles(0, 0, math.rad(90))},
{Texture = "4622077774", Mesh = "3030546036", Name = "International Fedora", Offset = CFrame.Angles(math.rad(-90), 0, math.rad(90))}
},
["Left Leg"] = {
{Texture = "17374768001", Mesh = "17374767929", Name = "Accessory (LARM)", Offset = CFrame.Angles(0, 0, math.rad(90))},
{Texture = "3860099469", Mesh = "3030546036", Name = "InternationalFedora", Offset = CFrame.Angles(math.rad(-90), 0, math.rad(-90))}
},
["Torso"] = {
{Texture = "13415110780", Mesh = "13421774668", Name = "MeshPartAccessory", Offset = CFrame.identity},
{Texture = "4819722776", Mesh = "4819720316", Name = "MeshPartAccessory", Offset = CFrame.Angles(0, 0, math.rad(-15))}
},
}
if WaitTime < 0.16 then WaitTime = 0/1 end
local Hats = Config.Hats or DefaultHats
local IsA = game.IsA
local FindFirstChildOfClass = game.FindFirstChildOfClass
local FindFirstChild = game.FindFirstChild
local WaitForChild = game.WaitForChild
local GetChildren = game.GetChildren
local GetDescendants = game.GetDescendants
local TeleportOffset = Vector3.zero
local ReverseSleep = TeleportOffset
local SafeYAxis = 35
local DefaultAccessoryPart1 = nil
local CameraHandle = nil
local MouseDown = nil
local HatsWithDifferentAligns = {}
local FlingableTargets = {}
local Joints = {}
local TempSignals = {}
local RBXSignals = {}
local HatsInUse = {}
local Blacklist = {}
local function GetInstanceWithTime(Parent, Class, Name, Timeout) -- <Any> <String> <String> <Number> : Instance
local CurTime = 0
while Timeout > CurTime do
for _, v in GetChildren(Parent) do
if IsA(v, Class) and (not Name or v.Name == Name) then
return v
end
end
CurTime += task.wait(0/1)
end
end
local Workspace = FindFirstChildOfClass(game, "Workspace") -- getservice not needed as they are preloaded servies
local Players = FindFirstChildOfClass(game, "Players")
local RunService = FindFirstChildOfClass(game, "RunService")
local StarterGui = FindFirstChildOfClass(game, "StarterGui")
local UserInputService = FindFirstChildOfClass(game, "UserInputService")
local Camera = Workspace.CurrentCamera
local PreviousCameraCFrame = Camera.CFrame
local KBMLookVector = Camera.CFrame.LookVector
local CamCustomType = Enum.CameraType.Custom
local IsMobile = UserInputService.TouchEnabled
local IsKeyboard = UserInputService.KeyboardEnabled
local Terrain = FindFirstChildOfClass(Workspace, "Terrain") -- Always present.
local RespawnEvent = Instance.new("BindableEvent")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait() and Player.Character
local Humanoid = GetInstanceWithTime(Character, "Humanoid", nil, 3)
local RootPart = GetInstanceWithTime(Character, "Part", "HumanoidRootPart", 3)
local Descendants = GetDescendants(Character)
local CFrameBackup = AntiVoiding and RootPart.CFrame or CFrame.identity
local FallenPartsDestroyHeight = Workspace.FallenPartsDestroyHeight + 75
local CanCallSimRadius = SetSimulationRadius and pcall(function() Player.SimulationRadius = 1000 end)
local FakeRig = Instance.new("Model")
local FakeHumanoid = Instance.new("Humanoid")
local FakeRigChildren = {}
local FakeRoot = nil
local Move = FakeHumanoid.Move
if FindFirstChild(Terrain, RigName) then
return
end
do -- [[ Scoped Rig Creating. ]]
local HumanoidDesc = Instance.new("HumanoidDescription")
local Animator = Instance.new("Animator")
local Animate = Instance.new("LocalScript")
local function MakeMotor6D(Name, Part0, Part1, C0, C1)
local Joint = Instance.new("Motor6D")
Joint.Name = Name
Joint.Part0 = Part0
Joint.Part1 = Part1
Joint.C0 = C0
Joint.C1 = C1
Joint.Parent = Part0
Joints[Name] = Joint
return Joint
end
local function MakeAttachment(Name, CFrame, Parent)
local Attachment = Instance.new("Attachment")
Attachment.Name = Name
Attachment.CFrame = CFrame
Attachment.Parent = Parent
end
local Torso = Instance.new("Part")
local RightArm = Instance.new("Part")
local Head = Instance.new("Part")
DefaultAccessoryPart1 = Head
Head.Size = Vector3.new(2,1,1)
Torso.Size = Vector3.new(2,2,1)
RightArm.Size = Vector3.new(1,2,1)
local Transparency = OverlayFakeCharacter and 0.5 or 1
Head.Transparency = Transparency
Torso.Transparency = Transparency
RightArm.Transparency = Transparency
FakeRoot = Torso:Clone()
FakeRoot.CanCollide = nil
local LeftArm = RightArm:Clone()
local RightLeg = RightArm:Clone()
local LeftLeg = RightArm:Clone()
FakeRoot.Name = "HumanoidRootPart"
Torso.Name = "Torso"
Head.Name = "Head"
RightArm.Name = "Right Arm"
LeftArm.Name = "Left Arm"
RightLeg.Name = "Right Leg"
LeftLeg.Name = "Left Leg"
Animator.Parent = FakeHumanoid
HumanoidDesc.Parent = FakeHumanoid
FakeHumanoid.Parent = FakeRig
FakeRoot.Parent = FakeRig
Head.Parent = FakeRig
Torso.Parent = FakeRig
RightArm.Parent = FakeRig
LeftArm.Parent = FakeRig
RightLeg.Parent = FakeRig
LeftLeg.Parent = FakeRig
FakeHumanoid.Parent = FakeRig
MakeMotor6D('Neck', Torso, Head, CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0), CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0))
MakeMotor6D('RootJoint', FakeRoot, Torso, CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0), CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0))
MakeMotor6D('Right Shoulder', Torso, RightArm, CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0), CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0))
MakeMotor6D('Left Shoulder', Torso, LeftArm, CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0))
MakeMotor6D('Right Hip', Torso, RightLeg, CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0), CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0))
MakeMotor6D('Left Hip', Torso, LeftLeg, CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0))
Animate.Name = "Animate"
Animate.Parent = FakeRig
FakeRig.Name = RigName
FakeRig.PrimaryPart = Head
FakeRig.Parent = Terrain
FakeHumanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
FakeHumanoid:ChangeState(Enum.HumanoidStateType.Landed)
if FakeRigScale then
FakeRig:ScaleTo(FakeRigScale)
FakeRoot.CFrame = RootPart.CFrame * CFrame.new(0, FakeRigScale + 0.1, 0)
else
FakeRoot.CFrame = RootPart.CFrame * CFrame.new(0, 0.1, 0)
end
if AccessoryFallbackDefaults then
local Types = {Name = "string", Texture = "string", Mesh = "string", Offset = "CFrame"}
for Name, Data in DefaultHats do
local HatsData = Hats[Name]
local Flagged = nil
if HatsData and typeof(HatsData) == "table" then
for _, Hat in ipairs(HatsData) do
for Key, Type in Types do
if typeof(Hat[Key]) ~= Type then
Flagged = true
break
end
end
end
else
Flagged = true
end
if Flagged then
Hats[Name] = table.clone(Data)
end
end
end
local Attachments = {
HairAttachment = {CFrame.new(0, 0.6, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), Head},
HatAttachment = {CFrame.new(0, 0.6, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), Head},
FaceFrontAttachment = {CFrame.new(0, 0, -0.6, 1, 0, 0, 0, 1, 0, 0, 0, 1), Head},
RootAttachment = {CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), FakeRoot},
LeftShoulderAttachment = {CFrame.new(0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), LeftArm},
LeftGripAttachment = {CFrame.new(0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), LeftArm},
RightShoulderAttachment = {CFrame.new(0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), RightArm},
RightGripAttachment = {CFrame.new(0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), RightArm},
LeftFootAttachment = {CFrame.new(0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), LeftLeg},
RightFootAttachment = {CFrame.new(0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), RightLeg},
NeckAttachment = {CFrame.new(0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
BodyFrontAttachment = {CFrame.new(0, 0, -0.5, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
BodyBackAttachment = {CFrame.new(0, 0, 0.5, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
LeftCollarAttachment = {CFrame.new(-1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
RightCollarAttachment = {CFrame.new(1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
WaistFrontAttachment = {CFrame.new(0, -1, -0.5, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
WaistCenterAttachment = {CFrame.new(0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso},
WaistBackAttachment = {CFrame.new(0, -1, 0.5, 1, 0, 0, 0, 1, 0, 0, 0, 1), Torso}
}
for Name, Table in Attachments do
MakeAttachment(Name, Table[1], Table[2])
end
table.clear(Attachments)
if Animations then
local function AddAnimation(ID)
local Animation = Instance.new("Animation")
Animation.AnimationId = ID
return Animation
end
local AnimationsToggled = true
local JumpAnimTime = 0
local Current = {
Speed = 0,
Animation = "",
Instance = nil,
AnimTrack = nil,
KeyframeHandler = nil
}
local AnimationTable = {
Idle = AddAnimation("http://www.roblox.com/asset/?id=180435571"),
Walk = AddAnimation("http://www.roblox.com/asset/?id=180426354"),
Run = AddAnimation("Run.xml"),
Jump = AddAnimation("http://www.roblox.com/asset/?id=125750702"),
Fall = AddAnimation("http://www.roblox.com/asset/?id=180436148"),
Climb = AddAnimation("http://www.roblox.com/asset/?id=180436334"),
Sit = AddAnimation("http://www.roblox.com/asset/?id=178130996"),
dance1 = AddAnimation("http://www.roblox.com/asset/?id=182435998"),
dance2 = AddAnimation("http://www.roblox.com/asset/?id=182436842"),
dance3 = AddAnimation("http://www.roblox.com/asset/?id=182436935"),
wave = AddAnimation("http://www.roblox.com/asset/?id=128777973"),
point = AddAnimation("http://www.roblox.com/asset/?dan=128853357"),
laugh = AddAnimation("http://www.roblox.com/asset/?id=129423131"),
cheer = AddAnimation("http://www.roblox.com/asset/?id=129423030")
}
local function PlayAnimation(AnimName, TransitionTime)
local Anim = AnimationTable[AnimName]
if Anim ~= Current.Instance then
if Current.AnimTrack then
Current.AnimTrack:Stop(TransitionTime)
Current.AnimTrack:Destroy()
end
Current.Speed = 1.0
Current.AnimTrack = FakeHumanoid:LoadAnimation(Anim)
Current.AnimTrack.Priority = Enum.AnimationPriority.Core
Current.AnimTrack:Play(TransitionTime)
Current.Animation = AnimName
Current.Instance = Anim
if Current.KeyframeHandler then
Current.KeyframeHandler:Disconnect()
end
Current.KeyframeHandler = Current.AnimTrack.KeyframeReached:Connect(function(FrameName)
if FrameName == "End" and AnimationTable[Current.Animation] then
PlayAnimation("Idle", 0.1)
end
end)
end
end
local function SetAnimationSpeed(Speed)
Current.Speed = Speed
Current.AnimTrack:AdjustSpeed(Speed)
end
local EventHandlers = {
Running = function(Speed)
if Speed > 0.01 then
PlayAnimation("Walk", 0.1)
SetAnimationSpeed(Speed / 14.5)
else
PlayAnimation("Idle", 0.1)
end
end,
Jumping = function()
PlayAnimation("Jump", 0.1)
JumpAnimTime = 0.3
end,
Climbing = function(Speed)
PlayAnimation("Climb", 0.1)
SetAnimationSpeed(Speed / 12.0)
end,
FreeFalling = function()
if JumpAnimTime <= 0 then
PlayAnimation("Fall", 0.3)
end
end
}
for EventName, Handler in EventHandlers do
FakeHumanoid[EventName]:Connect(function(...)
if AnimationsToggled then
Handler(...)
end
end)
end
table.insert(RBXSignals, Player.Chatted:Connect(function(Message)
local Context = Message and string.gsub(Message, "/e ", "")
if AnimationsToggled and AnimationTable[Context] then
PlayAnimation(Context, 0.1)
end
end))
table.insert(RBXSignals, RunService.PostSimulation:Connect(function(DeltaTime)
AnimationsToggled = Animate and Animate.Parent and Animate.Enabled
JumpAnimTime = math.max(0, JumpAnimTime - DeltaTime)
end))
end
end
-- // RunTime: Functions
local function ForceSetProperty(Instance, Property, Value) -- <Instance | Table> <String>, <Any> : nil
return pcall(function()
Instance[Property] = Value
end)
end
local function ExtractNumbers(String) -- <String> : string
return string.match(String, "%d+")
end
local function GetFirstPart(Parent) -- <Any> : Part | BasePart
return FindFirstChildOfClass(Parent, "Part") or WaitForChild(Parent, "Handle", 1)
end
local function GetFirstWeld(Parent) -- <Any> : Weld | ManualWeld
return FindFirstChild(Parent, "AccessoryWeld") or FindFirstChildOfClass(Parent, "Weld")
end
local function DestroyWeld(Parent) -- <Instance>
local Weld = GetFirstWeld(Parent)
if Weld then
Weld:Destroy()
end
end
local function ObtainMeshAndTextureOfAccessory(Accessory) -- <Accessory> : {MeshId: string, TextureId: string}
local Handle = FindFirstChild(Accessory, "Handle")
local IfMesh = FindFirstChildOfClass(Handle, "SpecialMesh")
if IsA(Handle, "MeshPart") then
return {MeshId = Handle.MeshId, TextureId = Handle.TextureID}
elseif IfMesh then
return {MeshId = IfMesh.MeshId, TextureId = IfMesh.TextureId}
end
end
local function FindAccessory(Parent, Texture, Mesh, Name) -- <Instance> <string> <string> <string> : Accessory
local InputMeshNumber = ExtractNumbers(Mesh)
local InputTextureNumber = ExtractNumbers(Texture)
for _, Accessory in GetChildren(Parent) do
if IsA(Accessory, "Accessory") and Accessory.Name == Name then
local HatData = ObtainMeshAndTextureOfAccessory(Accessory)
if HatData then
local MeshNumber = ExtractNumbers(HatData.MeshId)
local TextureNumber = ExtractNumbers(HatData.TextureId)
if MeshNumber == InputMeshNumber and TextureNumber == InputTextureNumber then
return Accessory
end
end
end
end
end
local function RecreateAccessory(Accessory) -- <Accessory> : Accessory
local FakeAccessory = Accessory:Clone()
local FakeHandle = GetFirstPart(FakeAccessory)
local FakeAttachment = FindFirstChildOfClass(FakeHandle, "Attachment")
local RigAttachment = FakeAttachment and FindFirstChild(FakeRig, FakeAttachment.Name or "", true)
local Weld = Instance.new("Weld")
FakeHandle.Transparency = 1
Weld.Name = "AccessoryWeld"
Weld.Part0 = FakeHandle
Weld.C0 = FakeAttachment and FakeAttachment.CFrame or CFrame.identity
DestroyWeld(FakeHandle)
if RigAttachment then
Weld.C1 = RigAttachment.CFrame
Weld.Part1 = RigAttachment.Parent
else
Weld.Part1 = DefaultAccessoryPart1
end
Weld.Parent = FakeHandle
FakeAccessory.Parent = FakeRig
return FakeAccessory
end
local function ProcessAccessory(Accessory, Function) -- <Accessory> <function> : BasePart
if not Accessory or table.find(Blacklist, Accessory) then
return
end
table.insert(Blacklist, Accessory)
local Handle = GetFirstPart(Accessory)
if Handle and not HatsInUse[Handle] then
Function(Handle)
end
end
local function SetUpHatConfig() -- : nil
for _, Hat in GetDescendants(FakeRig) do
if IsA(Hat, "Accessory") then
Hat:Destroy()
end
end
for _, Value in HatsWithDifferentAligns do
local Accessory = FindAccessory(Character, Value[1], Value[2], Value[3])
ProcessAccessory(Accessory, function(Handle)
local Part1 = Value[4]
if Part1 and Part1.Parent then
HatsInUse[Handle] = {Part1, Value[5] or CFrame.identity}
end
end)
end
for Index, Data in Hats do
for _, Info in Data do
local Accessory = FindAccessory(Character, Info.Texture, Info.Mesh, Info.Name)
ProcessAccessory(Accessory, function(Handle)
HatsInUse[Handle] = {FindFirstChild(FakeRig, Index), Info.Offset}
end)
if LimitHatsPerLimb then
continue
end
end
end
for _, Accessory in GetChildren(Character) do
if IsA(Accessory, "Accessory") then
ProcessAccessory(Accessory, function(Handle)
local FakeAccessory = RecreateAccessory(Accessory)
HatsInUse[Handle] = {GetFirstPart(FakeAccessory), CFrame.identity}
end)
end
end
end
local function ConnectHats(Part0, Part1, Offset) -- : nil
if Part0 and Part1 and Part0.Parent and Part1.Parent and Part0.ReceiveAge == 0 then
if ShowClientHats then
Part1.Transparency = 1
end
local Part1Magnitude = Part1.Size.Magnitude
local Part1Velocity = Part1.AssemblyLinearVelocity * Part1Magnitude
local CalculatedVel = Part1Velocity * 2.5
local ClampedAxisY = math.clamp(Part1Velocity.Y, SafeYAxis, 512)
local Velocity = Vector3.new(CalculatedVel.X, ClampedAxisY, CalculatedVel.Z)
local CFrameOffset = Part1.CFrame * Offset
Part0.AssemblyLinearVelocity = Velocity
Part0.AssemblyAngularVelocity = Part1.AssemblyAngularVelocity
Part0.CFrame = CFrameOffset + ReverseSleep
elseif ShowClientHats then
Part1.Transparency = 0.5
end
end
local function GetRandomRadius() -- : Vector3
return Vector3.new(math.random(-TeleportOffsetRadius, TeleportOffsetRadius), 0.5, math.random(-TeleportOffsetRadius, TeleportOffsetRadius))
end
local function ArePlayersNearby() -- : Boolean
local Output = nil
for _, Part in Workspace:GetPartBoundsInRadius(TeleportOffset, 10) do
local Model = Part.Parent
if IsA(Model, "Model") then
if FindFirstChildOfClass(Model, "Humanoid") and not (Model == Character and Model == FakeRig) then
Output = true
end
end
end
return Output
end
local function BringCharacter() -- : nil
local Time = 0
while WaitTime > Time do
if RootPart then
RootPart.AssemblyLinearVelocity = Vector3.new(0,-500,0) -- Can sometimes remove the root instantly, providing faster claim time!!!
RootPart.AssemblyAngularVelocity = Vector3.zero
RootPart.CFrame = CFrame.new(TeleportOffset)
end
Time += RunService.PostSimulation:Wait()
end
end
local function FlingModels() -- : nil
for _, Model in FlingableTargets do
local PrimaryPart = Model.PrimaryPart
if PrimaryPart then
for _ = 1, 16 do
RootPart.CFrame = CFrame.new(PrimaryPart.Position + PrimaryPart.AssemblyLinearVelocity * Player:GetNetworkPing()*30)
RootPart.AssemblyLinearVelocity = Vector3.new(16000, 16000, 16000)
if PrimaryPart.AssemblyAngularVelocity.Magnitude > 75 then
break
end
task.wait()
end
end
end
table.clear(FlingableTargets)
end
local function RespawnBring() -- : nil
if WaitTime > 0.16 then
TeleportOffset = FakeRoot.Position + GetRandomRadius() + Vector3.new(0, NoBodyNearby and FallenPartsDestroyHeight + 15 or 0, 0)
while ArePlayersNearby() do
TeleportOffset = FakeRoot.Position + GetRandomRadius() + Vector3.new(0, NoBodyNearby and FallenPartsDestroyHeight + 15 or 0, 0)
task.wait(0/1)
end
BringCharacter()
Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
Character:BreakJoints()
task.wait(0.125)
else
Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
Character:BreakJoints()
Descendants = GetDescendants(Character)
end
SetUpHatConfig()
if SetCharacter then
task.wait()
Player.Character = FakeRig
end
end
local function CancelScript() -- : nil
local Pos = FakeRoot.CFrame
CameraHandle:Disconnect()
for _, Signal in RBXSignals do
Signal:Disconnect()
end
StarterGui:SetCore("ResetButtonCallback", true)
Camera.CameraSubject = Character
FakeRig:Destroy()
-- Free the memory after use.
table.clear(Hats)
table.clear(HatsInUse)
table.clear(RBXSignals)
table.clear(FakeRigChildren)
table.clear(Joints)
table.clear(HatsWithDifferentAligns)
table.clear(FlingableTargets)
table.clear(TempSignals)
table.clear(DefaultHats)
table.clear(Descendants)
if ReturnOnDeath then
local Target = Player.CharacterAdded:Wait()
local Root = GetInstanceWithTime(Target, "Part", "HumanoidRootPart", 3)
if Root then
Root.CFrame = Pos
end
end
end
-- // RunTime: Event functions
local function UpdateCameraCFrame() -- Function | SIGNAL: Camera:GetPropertySignalChanged("CameraSubject")
PreviousCameraCFrame = Camera.CFrame
RunService.PreRender:Wait()
Camera.CFrame = PreviousCameraCFrame
end
local function OnInputChange(Input, GameProcessed, Bool) -- SIGNAL: UIS.InputBegan | UIS.InputEnded
if GameProcessed then
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
MouseDown = Bool
end
end
end
local function OnPresetFlingEnabled() -- SIGNAL: RunService.PostSimulation [Required: Flinging = true]
if not MouseDown then return end
local Target = Mouse.Target
local TargetParent = Target and Target.Parent
local TargetDescendant = TargetParent and TargetParent.Parent
local NewTarget = FindFirstChildOfClass(TargetParent, "Humanoid") or FindFirstChildOfClass(TargetDescendant, "Humanoid")
local HitCalciulation = CFrame.new(Mouse.Hit.Position)
if NewTarget then
local Part = GetFirstPart(NewTarget.Parent)
if Part then
RootPart.CFrame = CFrame.new(Part.Position + Part.AssemblyLinearVelocity * Player:GetNetworkPing())
else
RootPart.CFrame = HitCalciulation
end
RootPart.AssemblyLinearVelocity = Vector3.new(4096, 4096, 4096)
else
RootPart.CFrame = HitCalciulation
RootPart.AssemblyLinearVelocity = Vector3.zero
end
end
local function OnPostSimulation() -- SIGNAL: RunService.PostSimulation
for Handle, Data in HatsInUse do
ConnectHats(Handle, Data[1], Data[2])
end
if AntiVoiding and FakeRoot.Position.Y < FallenPartsDestroyHeight then
FakeRoot.CFrame = CFrameBackup
FakeRoot.AssemblyLinearVelocity = Vector3.zero
FakeRoot.AssemblyAngularVelocity = Vector3.zero
end
FakeHumanoid.Jump = Humanoid.Jump
Move(FakeHumanoid, Humanoid.MoveDirection)
end
local function OnPreRender() -- SIGNAL: RunService.PreSimulation
if Camera then
if Camera.CameraSubject ~= FakeHumanoid then
Camera.CameraSubject = FakeHumanoid
end
if Camera.CameraType ~= CamCustomType then
Camera.CameraSubject = CamCustomType
end
end
end
local function OnPreSimulation() -- SIGNAL: RunService.PreSimulation
StarterGui:SetCore("ResetButtonCallback", RespawnEvent)
ReverseSleep = Vector3.new(0.0075 * math.sin(os.clock() * 7), 0, 0.0065 * math.cos(os.clock() * 3))
SafeYAxis = 35 - 3 * math.sin(os.clock() * 10)
if CanCallSimRadius then
Player.SimulationRadius = 1000
end
for _, Part in Descendants do
if IsA(Part, "BasePart") then
Part.CanCollide = false
Part.CanTouch = false
Part.CanQuery = false
end
end
if NoCollisions then
for _, Part in FakeRigChildren do
if IsA(Part, "BasePart") then
Part.CanCollide = false
Part.CanTouch = false
Part.CanQuery = false
end
end
end
end
local function OnCharacterAdded(NewCharacter) -- SIGNAL : Player.CharacterAdded
UpdateCameraCFrame()
if NewCharacter ~= FakeRig then
table.clear(HatsInUse)
table.clear(Descendants)
table.clear(FakeRigChildren)
table.clear(Blacklist)
Character = NewCharacter
Humanoid = GetInstanceWithTime(Character, "Humanoid", nil, 3)
RootPart = GetInstanceWithTime(Character, "Part", "HumanoidRootPart", 3)
if Humanoid and RootPart then
if DisableCharacterScripts then
for _, Script in Descendants do
if IsA(Script, "LocalScript") then
Script.Disabled = true
end
end
end
if Flinging then
if PresetFling then
local TemporarySignal = RunService.PostSimulation:Connect(OnPresetFlingEnabled)
repeat task.wait() until not MouseDown
TemporarySignal:Disconnect()
TemporarySignal = nil
else
FlingModels()
end
end
-- RootPart.Transparency = 0.5
ForceSetProperty(FindFirstChild(FakeRoot, "Died"), "Volume", 0)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
FakeRigChildren = GetChildren(FakeRig)
task.defer(RespawnBring)
end
end
end
local function UponParentChange() -- SIGNAL: FakeRig:GetPropertyChangedSignal("Parent")
if not FakeRig:IsDescendantOf(Workspace) then
CancelScript()
end
end
local function UponCameraChange(NewCamera) -- SIGNAL: Workspace:GetPropertyChangedSignal("CurrentCamera")
CameraHandle:Disconnect()
Camera = NewCamera
CameraHandle = Camera:GetPropertyChangedSignal("CameraSubject"):Connect(UpdateCameraCFrame)
end
UpdateCameraCFrame()
SetUpHatConfig()
ForceSetProperty(FindFirstChild(FakeRoot, "Died"), "Volume", 0)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
table.insert(RBXSignals, Player.CharacterAdded:Connect(OnCharacterAdded))
table.insert(RBXSignals, RunService.PostSimulation:Connect(OnPostSimulation))
table.insert(RBXSignals, RunService.PreSimulation:Connect(OnPreSimulation))
table.insert(RBXSignals, RunService.PreRender:Connect(OnPreRender))
table.insert(RBXSignals, FakeRoot:GetPropertyChangedSignal("Parent"):Connect(UponParentChange))
table.insert(RBXSignals, RespawnEvent.Event:Connect(CancelScript))
table.insert(RBXSignals, UserInputService.InputBegan:Connect(function(Input, GameProcessed) OnInputChange(Input, not GameProcessed, true) end))
table.insert(RBXSignals, UserInputService.InputEnded:Connect(function(Input, GameProcessed) OnInputChange(Input, not GameProcessed, nil) end))
table.insert(RBXSignals, Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(UponCameraChange))
CameraHandle = Camera:GetPropertyChangedSignal("CameraSubject"):Connect(UpdateCameraCFrame)
if SetCharacter then
Player.Character = FakeRig
end
task.defer(RespawnBring)
FakeRigChildren = GetChildren(FakeRig)
return {
GetCharacter = function() -- Returns FakeRig Model, needed for scripts.
return FakeRig
end,
GetHumanoid = function() -- Returns GetHumanoid
return FakeHumanoid
end,
GetRootPart = function() -- Returns HumanoidRootPart
return FakeRoot
end,
GetHatInformation = function(Hat) -- Returns HumanoidRootPart
local HatInfo = ObtainMeshAndTextureOfAccessory(Hat)
HatInfo.Name = Hat.Name
return HatInfo
end,
GetRealCharacter = function(Name) -- Returns RealRig Model, needed for scripts.
repeat task.wait() until Player.Character
return Player.Character
end,
SetHatAlign = function(HatInformation, Part1, Offset) -- Aligns Hat.
assert(typeof(HatInformation) == "table", "HatInformation is not an table.")
assert(Part1 and Part1:IsA("BasePart"), "Part1 is not a part.")
assert(typeof(Offset) == "CFrame", "Offset is not a part.")
local TextureId = HatInformation.TextureId
local MeshId = HatInformation.MeshId
local Name = HatInformation.Name
local Accessory = nil
local Timeout = 3
local Current = 0
while not Accessory and Timeout > Current do
Accessory = FindAccessory(Player.Character, TextureId, MeshId, Name)
Current += task.wait()
end
if not Accessory then
error("Accessory has not been found in Character.")
end
local Handle = GetFirstPart(Accessory)
if Handle then
local Dictionary = table.find(HatsInUse, Handle)
table.remove(HatsInUse, Dictionary)
table.insert(HatsWithDifferentAligns, {TextureId, MeshId, Name, Part1, Offset})
HatsInUse[Handle] = {Part1, Offset}
end
end,
DisconnectHatAlign = function(HatInformation) -- Disconnects hat
assert(typeof(HatInformation) == "table", "HatInformation is not an table.")
local Accessory = nil
local Timeout = 3
local Current = 0
while not Accessory and Timeout > Current do
Accessory = FindAccessory(Character, HatInformation.TextureId, HatInformation.MeshId, HatInformation.Name)
Current += task.wait()
end
if not Accessory then
error("Accessory has not been found in Character.")
end
local Handle = GetFirstPart(Accessory)
for Table, Value in HatsWithDifferentAligns do
local UsedAccessory = FindAccessory(Character, Value[1], Value[2], Value[3])
if UsedAccessory and UsedAccessory == Accessory then
local UsedHandle = GetFirstPart(UsedAccessory)
local Dictionary = table.find(HatsInUse, UsedHandle)
table.remove(HatsInUse, Dictionary)
local Dictionary2 = table.find(HatsWithDifferentAligns, Table) -- seems ugly but idc
table.remove(HatsWithDifferentAligns, Dictionary)
if UsedHandle then
local FakeAccessory = RecreateAccessory(UsedAccessory)
if FakeAccessory then
HatsInUse[UsedHandle] = {GetFirstPart(FakeAccessory), CFrame.identity}
end
end
end
end
end,
SWait = task.wait, -- Stepped Wait
SetAnimationState = function(Status) -- Stops Animations
local Animator = FindFirstChildOfClass(FakeHumanoid, "Animator")
local Animate = FindFirstChild(FakeRig, "Animate")
if Animate then
Animate.Disabled = not Status
end
if not Status and Animator then
for _, Track in Animator:GetPlayingAnimationTracks() do
Track:Stop()
end