-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathvr.lua
More file actions
1678 lines (1621 loc) · 66 KB
/
vr.lua
File metadata and controls
1678 lines (1621 loc) · 66 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
-- | made by 0866 and Abacaxl
-- | tysm unverified
--[[---------Settings---------]]--
local game = game
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local sethidden = sethiddenproperty or set_hidden_property or set_hidden_prop
coroutine.wrap(function()
while wait() do
sethidden(Players.LocalPlayer, "SimulationRadius", math.huge)
sethidden(Players.LocalPlayer, "MaximumSimulationRadius", math.huge)
end
end)()
RunService.Stepped:Connect(function()
sethidden(Players.LocalPlayer, "SimulationRadius", math.huge)
Players.LocalPlayer.MaximumSimulationRadius = math.huge
end)
local bodyTransparency = 0 --Change the transparency of your character (0 - 1)
local bodyVelocity = {-17.7, 0, -17.7} --Change your body parts velocity. First number value is the X value. Second number value is the Y value. Third number value is the Z value.
local hatVelocity = {-17.7, 0, -17.7} --Change your accessory's velocity. First number value is the X value. Second number value is the Y value. Third number value is the Z value.
--Velocity is not recommended to be (-17.7, 0, -17.7) in R15 since body parts often fall in R15.
--[[--------------------------]]--
local player1 = Players.LocalPlayer
local character1 = player1.Character
--Fake Character--
--Create Attachment Function
local function CreateAttachment(parent, position, orientation, axis, secondaryAxis, name)
local newAttchment = Instance.new("Attachment", parent)
newAttchment.Position = position
newAttchment.Orientation = orientation
newAttchment.Axis = axis
newAttchment.SecondaryAxis = secondaryAxis
newAttchment.Name = name
end
--Variables
local player1 = Players.LocalPlayer
local character1 = player1.Character
local hrp = character1.HumanoidRootPart
for i,v in pairs(character1:GetChildren()) do
if v:IsA("LocalScript") then
v:Destroy()
end
end
local camera = workspace.CurrentCamera
workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
camera = (workspace.CurrentCamera or workspace:FindFirstChild("Camera") or Instance.new("Camera"))
end)
local reanimFolder = Instance.new("Folder", character1)
reanimFolder.Name = "FakeCharacter"
local model = Instance.new("Model", reanimFolder)
model.Name = "Reanimation"
local userInputService = game:GetService("UserInputService")
local movingW, movingA, movingS, movingD, jumping = false
--Body Parts--
--Head
local cHead = Instance.new("Part")
cHead.Parent = model
cHead.Size = Vector3.new(2, 1, 1)
cHead.Name = "Head"
--Torso
local cTorso = Instance.new("Part")
cTorso.Parent = model
cTorso.Size = Vector3.new(2, 2, 1)
cTorso.Name = "Torso"
--Left Arm
local cLArm = Instance.new("Part")
cLArm.Parent = model
cLArm.Size = Vector3.new(1, 2, 1)
cLArm.Name = "Left Arm"
--Right Arm
local cRArm = Instance.new("Part")
cRArm.Parent = model
cRArm.Size = Vector3.new(1, 2, 1)
cRArm.Name = "Right Arm"
--Left Leg
local cLLeg = Instance.new("Part")
cLLeg.Parent = model
cLLeg.Size = Vector3.new(1, 2, 1)
cLLeg.Name = "Left Leg"
--Right Leg
local cRLeg = Instance.new("Part")
cRLeg.Parent = model
cRLeg.Size = Vector3.new(1, 2, 1)
cRLeg.Name = "Right Leg"
--HumanoidRootPart
local cHRP = Instance.new("Part")
cHRP.Parent = model
cHRP.Size = Vector3.new(2, 2, 1)
cHRP.Name = "HumanoidRootPart"
cHRP.Transparency = 1
cHRP.CanCollide = false
--Transparency
for i,v in pairs(model:GetChildren()) do
if v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
v.Transparency = 1--0.5
end
end
--Joints--
--Right Shoulder
local rShoulder = Instance.new("Motor6D")
rShoulder.Parent = cTorso
rShoulder.Part0 = cTorso
rShoulder.Part1 = cRArm
rShoulder.Name = "Right Shoulder"
rShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
rShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
--Left Shoulder
local lShoulder = Instance.new("Motor6D")
lShoulder.Parent = cTorso
lShoulder.Part0 = cTorso
lShoulder.Part1 = cLArm
lShoulder.Name = "Left Shoulder"
lShoulder.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
lShoulder.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
--Right Hip
local rHip = Instance.new("Motor6D")
rHip.Parent = cTorso
rHip.Part0 = cTorso
rHip.Part1 = cRLeg
rHip.Name = "Right Hip"
rHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
rHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
--Left Hip
local lHip = Instance.new("Motor6D")
lHip.Parent = cTorso
lHip.Part0 = cTorso
lHip.Part1 = cLLeg
lHip.Name = "Left Hip"
lHip.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
lHip.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
--Neck
local neck = Instance.new("Motor6D")
neck.Parent = cTorso
neck.Part0 = cTorso
neck.Part1 = cHead
neck.Name = "Neck"
neck.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
neck.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
--RootJoint
local rootJoint = Instance.new("Motor6D")
rootJoint.Parent = cHRP
rootJoint.Part0 = cHRP
rootJoint.Part1 = cTorso
rootJoint.Name = "RootJoint"
rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
rootJoint.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
--Humanoid--
local cHumanoid = Instance.new("Humanoid")
cHumanoid.Parent = model
cHumanoid.DisplayDistanceType = "None"
--Head Mesh--
local headMesh = Instance.new("SpecialMesh")
headMesh.Parent = cHead
headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
local reanimation = model
--Creating Attachments
CreateAttachment(cHead, Vector3.new(0,0.60000002384186,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "HairAttachment")
CreateAttachment(cHead, Vector3.new(0,0.60000002384186,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "HatAttachment")
CreateAttachment(cHead, Vector3.new(0,0,-0.60000002384186), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "FaceFrontAttachment")
CreateAttachment(cHead, Vector3.new(0,0,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "FaceCenterAttachment")
CreateAttachment(cTorso, Vector3.new(0,1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "NeckAttachment")
CreateAttachment(cTorso, Vector3.new(0,0,-0.5), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "BodyFrontAttachment")
CreateAttachment(cTorso, Vector3.new(0,0,0.5), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "BodyBackAttachment")
CreateAttachment(cTorso, Vector3.new(-1,1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "LeftCollarAttachment")
CreateAttachment(cTorso, Vector3.new(1,1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "RightCollarAttachment")
CreateAttachment(cTorso, Vector3.new(0,-1,-0.5), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "WaistFrontAttachment")
CreateAttachment(cTorso, Vector3.new(0,-1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "WaistCenterAttachment")
CreateAttachment(cTorso, Vector3.new(0,-1,0.5), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "WaistBackAttachment")
CreateAttachment(cLArm, Vector3.new(0,1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "LeftShoulderAttachment")
CreateAttachment(cLArm, Vector3.new(0,-1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "LeftGripAttachment")
CreateAttachment(cRArm, Vector3.new(0,1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "RightShoulderAttachment")
CreateAttachment(cRArm, Vector3.new(0,-1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "RightGripAttachment")
CreateAttachment(cLLeg, Vector3.new(0,-1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "LeftFootAttachment")
CreateAttachment(cRLeg, Vector3.new(0,-1,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "RightFootAttachment")
CreateAttachment(cHRP, Vector3.new(0,0,0), Vector3.new(-0,0,0), Vector3.new(1,0,0), Vector3.new(0,1,0), "RootAttachment")
--Cloning Hats (For Netless)
for i,v in pairs(character1:GetChildren()) do
if v:IsA("Accessory") then
local clone = v:Clone()
local weld = v.Handle:FindFirstChildWhichIsA("Weld")
local weldPart1 = weld.Part1
local newWeld = Instance.new("Weld")
newWeld.Parent = clone.Handle
local CFrame0 = v.Handle.AccessoryWeld.C0
local CFrame1 = v.Handle.AccessoryWeld.C1
clone.Handle:FindFirstChild("AccessoryWeld"):Destroy()
clone.Parent = reanimation
newWeld.Name = "AccessoryWeld"
newWeld.C0 = CFrame0
newWeld.C1 = CFrame1
newWeld.Part0 = clone.Handle
newWeld.Part1 = character1:FindFirstChild(weldPart1.Name)
clone.Handle.Transparency = 1
end
end
cHRP.CFrame = hrp.CFrame
-- CLOVR - FE FULL-BODY VR SCRIPT
-- April 21st Update - TOOL HOLDING ADDED
-- | made by 0866 and Abacaxl
-- | tysm unverified
--RagdollEnabled is set to true, DON'T set it to false or CLOVR won't work. Feel free to change the other settings though. -Abacaxl
--|| Settings:
local StudsOffset = 0 -- Character height (negative if you're too high)
local Smoothness = .5 -- Character interpolation (0.1 - 1 = smooth - rigid)
local AnchorCharacter = false -- Prevent physics from causing inconsistencies
local HideCharacter = false -- Hide character on a platform
local NoCollision = true-- Disable player collision
local ChatEnabled = true -- See chat on your left hand in-game
local ChatLocalRange = 75 -- Local chat range
local ViewportEnabled = true -- View nearby players in a frame
local ViewportRange = 30 -- Maximum distance players are updated
local RagdollEnabled = true -- Use your character instead of hats (NetworkOwner vulnerability)
local RagdollHeadMovement = true -- Move your head separately from your body (+9 second wait)
local AutoRun = false -- Run script on respawn
local AutoRespawn = true -- Kill your real body when your virtual body dies
local WearAllAccessories = true -- Use all leftover hats for the head
local AccurateHandPosition = true -- Move your Roblox hands according to your real hands
local AccessorySettings = {
LeftArm = "",
RightArm = "",
LeftLeg = "",
RightLeg = "",
Torso = "",
Head = true,
BlockArms = true,
BlockLegs = true,
BlockTorso = true,
LimbOffset = CFrame.Angles(math.rad(90), 0, 0)
}
local FootPlacementSettings = {
RightOffset = Vector3.new(.5, 0, 0),
LeftOffset = Vector3.new(-.5, 0, 0)
}
--|| Script:
local Script = nil
Script = function()
--[[
Variables
--]]
local Client = Players.LocalPlayer
local Character = Client.Character or Client.CharacterAdded:Wait()
local WeldBase = Character:WaitForChild("HumanoidRootPart")
local ArmBase = Character:FindFirstChild("RightHand") or Character:FindFirstChild("Right Arm") or WeldBase
local Backpack = Client:WaitForChild("Backpack")
local Mouse = Client:GetMouse()
local Camera = workspace.CurrentCamera
local VRService = game:GetService("VRService")
local VRReady = VRService.VREnabled
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local HttpService = game:GetService("HttpService")
local StarterGui = game:GetService("StarterGui")
local HeadAccessories = {}
local UsedAccessories = {}
local Pointer = false
local Point1 = false
local Point2 = false
local VirtualRig = game:GetObjects("rbxassetid://4468539481")[1]
local VirtualBody = game:GetObjects("rbxassetid://4464983829")[1]
local Anchor = Instance.new("Part")
Anchor.Anchored = true
Anchor.Transparency = 1
Anchor.CanCollide = false
Anchor.Parent = workspace
--[[
if RagdollEnabled then
local NetworkAccess =
coroutine.create(
function()
settings().Physics.AllowSleep = false
while true do
game:GetService("RunService").RenderStepped:Wait()
for _, Players in next, game:GetService("Players"):GetChildren() do
if Players ~= game:GetService("Players").LocalPlayer then
Players.MaximumSimulationRadius = 0.1
Players.SimulationRadius = 0
end
end
game:GetService("Players").LocalPlayer.MaximumSimulationRadius = math.pow(math.huge, math.huge)
game:GetService("Players").LocalPlayer.SimulationRadius = math.huge * math.huge
end
end
)
coroutine.resume(NetworkAccess)
end
]]
StarterGui:SetCore("VRLaserPointerMode", 3)
--[[
Character Protection
--]]
local CharacterCFrame = WeldBase.CFrame
if not RagdollEnabled then
Character:FindFirstChild("Humanoid").AnimationPlayed:Connect(
function(Animation)
Animation:Stop()
end
)
for _, Track in next, Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks() do
Track:Stop()
end
if HideCharacter then
local Platform = Instance.new("Part")
Platform.Anchored = true
Platform.Size = Vector3.new(100, 5, 100)
Platform.CFrame = CFrame.new(0, 10000, 0)
Platform.Transparency = 1
Platform.Parent = workspace
Character:MoveTo(Platform.Position + Vector3.new(0, 5, 0))
wait(.5)
end
if AnchorCharacter then
for _, Part in pairs(Character:GetChildren()) do
if Part:IsA("BasePart") then
Part.Anchored = true
end
end
end
end
--[[
Functions
--]]
function Tween(Object, Style, Direction, Time, Goal)
local tweenInfo = TweenInfo.new(Time, Enum.EasingStyle[Style], Enum.EasingDirection[Direction])
local tween = game:GetService("TweenService"):Create(Object, tweenInfo, Goal)
tween.Completed:Connect(
function()
tween:Destroy()
end
)
tween:Play()
return tween
end
local function GetMotorForLimb(Limb)
for _, Motor in next, Character:GetDescendants() do
if Motor:IsA("Motor6D") and Motor.Part1 == Limb then
return Motor
end
end
end
local function CreateAlignment(Limb, Part0)
local Attachment0 = Instance.new("Attachment")
Attachment0.Parent = Part0 or Anchor
local Attachment1 = Instance.new("Attachment")
Attachment1.Parent = Limb
local Orientation = Instance.new("AlignOrientation")
local Position = Instance.new("AlignPosition")
Orientation.Attachment0 = Attachment1
Orientation.Attachment1 = Attachment0
Orientation.RigidityEnabled = false
Orientation.MaxTorque = 20000
Orientation.Responsiveness = 40
Orientation.Parent = reanimation["HumanoidRootPart"]
Orientation.Name = Limb.Name.."'s AlignRot"
Orientation.MaxAngularVelocity = 100
Position.Attachment0 = Attachment1
Position.Attachment1 = Attachment0
Position.RigidityEnabled = false
Position.MaxForce = 40000
Position.Responsiveness = 40
Position.Parent = reanimation["HumanoidRootPart"]
Position.Name = Limb.Name.."'s AlignPos"
Position.MaxVelocity = 100
Limb.Massless = false
local Motor = GetMotorForLimb(Limb)
if Motor then
Motor:Destroy()
end
return function(CF, Local)
if Local then
Attachment0.CFrame = CF
else
Attachment0.WorldCFrame = CF
end
end
end
local function GetExtraTool()
for _, Tool in next, Character:GetChildren() do
if Tool:IsA("Tool") and not Tool.Name:match("LIMB_TOOL") then
return Tool
end
end
end
local function GetGripForHandle(Handle)
for _, Weld in next, Character:GetDescendants() do
if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
return Weld
end
end
wait(.2)
for _, Weld in next, Character:GetDescendants() do
if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
return Weld
end
end
end
local function CreateRightGrip(Handle)
local RightGrip = Instance.new("Weld")
RightGrip.Name = "RightGrip"
RightGrip.Part1 = Handle
RightGrip.Part0 = WeldBase
RightGrip.Parent = WeldBase
return RightGrip
end
local function CreateAccessory(Accessory, DeleteMeshes)
if not Accessory then
return
end
local HatAttachment = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
local HeadAttachment = VirtualRig:FindFirstChild(HatAttachment.Name, true)
local BasePart = HeadAttachment.Parent
local HatAtt = HatAttachment.CFrame
local HeadAtt = HeadAttachment.CFrame
if DeleteMeshes then
if Accessory.Handle:FindFirstChild("Mesh") then
Accessory.Handle.Mesh:Destroy()
end
end
wait()
local Handle = Accessory:WaitForChild("Handle")
if Handle:FindFirstChildWhichIsA("Weld", true) then
Handle:FindFirstChildWhichIsA("Weld", true):Destroy()
Handle:BreakJoints()
else
Handle:BreakJoints()
end
Handle.Massless = true
Handle.Transparency = 0.5
UsedAccessories[Accessory] = true
local RightGrip = CreateRightGrip(Handle)
wait()
for _, Object in pairs(Handle:GetDescendants()) do
if not Object:IsA("BasePart") then
pcall(
function()
Object.Transparency = 1
end
)
pcall(
function()
Object.Enabled = false
end
)
end
end
return Handle, RightGrip, HatAtt, HeadAtt, BasePart
end
local function GetHeadAccessories()
for _, Accessory in next, Character:GetChildren() do
if Accessory:IsA("Accessory") and not UsedAccessories[Accessory] then
local Handle, RightGrip, HatAtt, HeadAtt, BasePart = CreateAccessory(Accessory)
table.insert(HeadAccessories, {Handle, RightGrip, HatAtt, HeadAtt, BasePart})
do
Handle.Transparency = 1
end
if not WearAllAccessories then
break
end
end
end
end
--[[
VR Replication Setup
--]]
if not RagdollEnabled then
LeftHandle, LeftHandGrip =
CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftArm), AccessorySettings.BlockArms)
RightHandle, RightHandGrip =
CreateAccessory(Character:FindFirstChild(AccessorySettings.RightArm), AccessorySettings.BlockArms)
LeftHipHandle, LeftLegGrip =
CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftLeg), AccessorySettings.BlockLegs)
RightHipHandle, RightLegGrip =
CreateAccessory(Character:FindFirstChild(AccessorySettings.RightLeg), AccessorySettings.BlockLegs)
TorsoHandle, TorsoGrip =
CreateAccessory(Character:FindFirstChild(AccessorySettings.Torso), AccessorySettings.BlockTorso)
GetHeadAccessories()
elseif RagdollEnabled then
if RagdollHeadMovement then
Permadeath()
MoveHead = CreateAlignment(reanimation["Head"])
end
MoveRightArm = CreateAlignment(reanimation["Right Arm"])
MoveLeftArm = CreateAlignment(reanimation["Left Arm"])
MoveRightLeg = CreateAlignment(reanimation["Right Leg"])
MoveLeftLeg = CreateAlignment(reanimation["Left Leg"])
MoveTorso = CreateAlignment(reanimation["Torso"])
MoveRoot = CreateAlignment(reanimation["HumanoidRootPart"])
--
if RagdollHeadMovement then
for _, Accessory in next, reanimation:GetChildren() do
if Accessory:IsA("Accessory") and Accessory:FindFirstChild("Handle") then
local Attachment1 = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
local Attachment0 = reanimation:FindFirstChild(tostring(Attachment1), true)
local Orientation = Instance.new("AlignOrientation")
local Position = Instance.new("AlignPosition")
Orientation.Attachment0 = Attachment1
Orientation.Attachment1 = Attachment0
Orientation.RigidityEnabled = false
Orientation.ReactionTorqueEnabled = true
Orientation.MaxTorque = 20000
Orientation.Responsiveness = 40
Orientation.Parent = reanimation["Head"]
Position.Attachment0 = Attachment1
Position.Attachment1 = Attachment0
Position.RigidityEnabled = false
Position.ReactionForceEnabled = true
Position.MaxForce = 40000
Position.Responsiveness = 40
Position.Parent = reanimation["Head"]
end
end
end
end
--[[
Movement
--]]
VirtualRig.Name = "VirtualRig"
VirtualRig.RightFoot.BodyPosition.Position = CharacterCFrame.p
VirtualRig.LeftFoot.BodyPosition.Position = CharacterCFrame.p
VirtualRig.Parent = workspace
VirtualRig:SetPrimaryPartCFrame(CharacterCFrame)
VirtualRig:FindFirstChildOfClass("Humanoid").Health = 0
--VirtualRig:FindFirstChild("HumanoidRootPart").CFrame = character1.HumanoidRootPart.CFrame
VirtualRig:BreakJoints()
for i,v in pairs(VirtualRig:GetChildren()) do
if v:IsA("BasePart") then
v.CFrame = character1.HumanoidRootPart.CFrame
end
end
--
VirtualBody.Parent = workspace
VirtualBody.Name = "VirtualBody"
VirtualBody:FindFirstChildOfClass("Humanoid").WalkSpeed = 8
VirtualBody:FindFirstChildOfClass("Humanoid").CameraOffset = Vector3.new(0, StudsOffset, 0)
VirtualBody:SetPrimaryPartCFrame(CharacterCFrame)
VirtualBody:FindFirstChildOfClass("Humanoid").Died:Connect(
function()
if AutoRespawn then
Character:BreakJoints()
if RagdollHeadMovement and RagdollEnabled then
--Network:Unclaim()
Respawn()
end
end
end
)
--
Camera.CameraSubject = VirtualBody:FindFirstChildOfClass("Humanoid")
Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 0
Character:FindFirstChildOfClass("Humanoid").JumpPower = 1
for _, Part in next, VirtualBody:GetChildren() do
if Part:IsA("BasePart") then
Part.Transparency = 1
end
end
for _, Part in next, VirtualRig:GetChildren() do
if Part:IsA("BasePart") then
Part.Transparency = 1
end
end
if not VRReady then
VirtualRig.RightUpperArm.ShoulderConstraint.RigidityEnabled = true
VirtualRig.LeftUpperArm.ShoulderConstraint.RigidityEnabled = true
end
local OnMoving =
RunService.Stepped:Connect(
function()
local Direction = Character:FindFirstChildOfClass("Humanoid").MoveDirection
local Start = VirtualBody.HumanoidRootPart.Position
local Point = Start + Direction * 6
VirtualBody:FindFirstChildOfClass("Humanoid"):MoveTo(Point)
end
)
Character:FindFirstChildOfClass("Humanoid").Jumping:Connect(
function()
VirtualBody:FindFirstChildOfClass("Humanoid").Jump = true
end
)
UserInputService.JumpRequest:Connect(
function()
VirtualBody:FindFirstChildOfClass("Humanoid").Jump = true
end
)
--[[
VR Replication
--]]
if RagdollEnabled then
for _, Part in pairs(Character:GetDescendants()) do
if Part:IsA("BasePart") and Part.Name == "Handle" and Part.Parent:IsA("Accessory") then
Part.LocalTransparencyModifier = 1
elseif Part:IsA("BasePart") and Part.Transparency < 0.5 and Part.Name ~= "Head" then
Part.LocalTransparencyModifier = bodyTransparency
elseif Part:IsA("BasePart") and Part.Name == "Head" then
Part.LocalTransparencyModifier = 1
end
if not Part:IsA("BasePart") and not Part:IsA("AlignPosition") and not Part:IsA("AlignOrientation") then
pcall(
function()
Part.Transparency = 1
end
)
pcall(
function()
Part.Enabled = false
end
)
end
end
end
local FootUpdateDebounce = tick()
local function FloorRay(Part, Distance)
local Position = Part.CFrame.p
local Target = Position - Vector3.new(0, Distance, 0)
local Line = Ray.new(Position, (Target - Position).Unit * Distance)
local FloorPart, FloorPosition, FloorNormal =
workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character})
if FloorPart then
return FloorPart, FloorPosition, FloorNormal, (FloorPosition - Position).Magnitude
else
return nil, Target, Vector3.new(), Distance
end
end
local function Flatten(CF)
local X, Y, Z = CF.X, CF.Y, CF.Z
local LX, LZ = CF.lookVector.X, CF.lookVector.Z
return CFrame.new(X, Y, Z) * CFrame.Angles(0, math.atan2(LX, LZ), 0)
end
local FootTurn = 1
local function FootReady(Foot, Target)
local MaxDist
if Character:FindFirstChildOfClass("Humanoid").MoveDirection.Magnitude > 0 then
MaxDist = .5
else
MaxDist = 1
end
local PastThreshold = (Foot.Position - Target.Position).Magnitude > MaxDist
local PastTick = tick() - FootUpdateDebounce >= 2
if PastThreshold or PastTick then
FootUpdateDebounce = tick()
end
return PastThreshold or PastTick
end
local function FootYield()
local RightFooting = VirtualRig.RightFoot.BodyPosition
local LeftFooting = VirtualRig.LeftFoot.BodyPosition
local LowerTorso = VirtualRig.LowerTorso
local Yield = tick()
repeat
RunService.Stepped:Wait()
if
(LowerTorso.Position - RightFooting.Position).Y > 4 or
(LowerTorso.Position - LeftFooting.Position).Y > 4 or
((LowerTorso.Position - RightFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4 or
((LowerTorso.Position - LeftFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4
then
break
end
until tick() - Yield >= .17
end
local function UpdateFooting()
if not VirtualRig:FindFirstChild("LowerTorso") then
wait()
return
end
local Floor, FloorPosition, FloorNormal, Dist = FloorRay(VirtualRig.LowerTorso, 3)
Dist = math.clamp(Dist, 0, 5)
local FootTarget =
VirtualRig.LowerTorso.CFrame * CFrame.new(FootPlacementSettings.RightOffset) - Vector3.new(0, Dist, 0) +
Character:FindFirstChildOfClass("Humanoid").MoveDirection * (VirtualBody:FindFirstChildOfClass("Humanoid").WalkSpeed / 8) * 2
if FootReady(VirtualRig.RightFoot, FootTarget) then
VirtualRig.RightFoot.BodyPosition.Position = FootTarget.p
VirtualRig.RightFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
end
FootYield()
local FootTarget =
VirtualRig.LowerTorso.CFrame * CFrame.new(FootPlacementSettings.LeftOffset) - Vector3.new(0, Dist, 0) +
Character:FindFirstChildOfClass("Humanoid").MoveDirection * (VirtualBody:FindFirstChildOfClass("Humanoid").WalkSpeed / 8) * 2
if FootReady(VirtualRig.LeftFoot, FootTarget) then
VirtualRig.LeftFoot.BodyPosition.Position = FootTarget.p
VirtualRig.LeftFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
end
end
local function UpdateTorsoPosition()
if not RagdollEnabled then
if TorsoHandle then
local Positioning = VirtualRig.UpperTorso.CFrame
if not TorsoGrip or not TorsoGrip.Parent then
TorsoGrip = CreateRightGrip(TorsoHandle)
end
local Parent = TorsoGrip.Parent
TorsoGrip.C1 = CFrame.new()
TorsoGrip.C0 =
TorsoGrip.C0:Lerp(
WeldBase.CFrame:ToObjectSpace(Positioning * CFrame.new(0, -0.25, 0) * AccessorySettings.LimbOffset),
Smoothness
)
TorsoGrip.Parent = nil
TorsoGrip.Parent = Parent
end
else
local Positioning = VirtualRig.UpperTorso.CFrame
MoveTorso(Positioning * CFrame.new(0, -0.25, 0))
MoveRoot(Positioning * CFrame.new(0, -0.25, 0))
end
end
local function UpdateLegPosition()
if not RagdollEnabled then
if RightHipHandle then
local Positioning =
VirtualRig.RightLowerLeg.CFrame:Lerp(VirtualRig.RightFoot.CFrame, 0.5) + Vector3.new(0, 0.5, 0)
if not RightHipHandle or not RightHipHandle.Parent then
RightLegGrip = CreateRightGrip(RightHipHandle)
end
local Parent = RightLegGrip.Parent
RightLegGrip.C1 = CFrame.new()
RightLegGrip.C0 =
RightLegGrip.C0:Lerp(
WeldBase.CFrame:ToObjectSpace(Positioning * AccessorySettings.LimbOffset),
Smoothness
)
RightLegGrip.Parent = nil
RightLegGrip.Parent = Parent
end
if LeftHipHandle then
local Positioning =
VirtualRig.LeftLowerLeg.CFrame:Lerp(VirtualRig.LeftFoot.CFrame, 0.5) + Vector3.new(0, 0.5, 0)
if not LeftLegGrip or not LeftLegGrip.Parent then
LeftLegGrip = CreateRightGrip(LeftHipHandle)
end
local Parent = LeftLegGrip.Parent
LeftLegGrip.C1 = CFrame.new()
LeftLegGrip.C0 =
LeftLegGrip.C0:Lerp(
WeldBase.CFrame:ToObjectSpace(Positioning * AccessorySettings.LimbOffset),
Smoothness
)
LeftLegGrip.Parent = nil
LeftLegGrip.Parent = Parent
end
else
do
local Positioning =
VirtualRig.RightLowerLeg.CFrame:Lerp(VirtualRig.RightFoot.CFrame, 0.5) *
CFrame.Angles(0, math.rad(180), 0) +
Vector3.new(0, 0.5, 0)
MoveRightLeg(Positioning)
end
do
local Positioning =
VirtualRig.LeftLowerLeg.CFrame:Lerp(VirtualRig.LeftFoot.CFrame, 0.5) *
CFrame.Angles(0, math.rad(180), 0) +
Vector3.new(0, 0.5, 0)
MoveLeftLeg(Positioning)
end
end
end
local function OnUserCFrameChanged(UserCFrame, Positioning, IgnoreTorso)
local Positioning = Camera.CFrame * Positioning
if not IgnoreTorso then
UpdateTorsoPosition()
UpdateLegPosition()
end
if not RagdollEnabled then
if UserCFrame == Enum.UserCFrame.Head and AccessorySettings.Head then
for _, Table in next, HeadAccessories do
local Handle, RightGrip, HatAtt, HeadAtt, BasePart = unpack(Table)
local LocalPositioning = Positioning
if not RightGrip or not RightGrip.Parent then
RightGrip = CreateRightGrip(Handle)
Table[2] = RightGrip
end
local Parent = RightGrip.Parent
if BasePart then
LocalPositioning = BasePart.CFrame * HeadAtt
end
RightGrip.C1 = HatAtt
RightGrip.C0 = RightGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(LocalPositioning), Smoothness)
RightGrip.Parent = nil
RightGrip.Parent = Parent
end
elseif RightHandle and UserCFrame == Enum.UserCFrame.RightHand and AccessorySettings.RightArm then
local HandPosition = Positioning
local LocalPositioning = Positioning
if not RightHandGrip or not RightHandGrip.Parent then
RightHandGrip = CreateRightGrip(RightHandle)
end
if AccurateHandPosition then
HandPosition = HandPosition * CFrame.new(0, 0, 1)
end
if not VRReady then
local HeadRotation = Camera.CFrame - Camera.CFrame.p
HandPosition =
VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5) *
AccessorySettings.LimbOffset
--LocalPositioning = (HeadRotation + (HandPosition * CFrame.new(0, 0, 1)).p) * CFrame.Angles(math.rad(-45), 0, 0)
LocalPositioning = HandPosition * CFrame.new(0, 0, 1) * CFrame.Angles(math.rad(-180), 0, 0)
if Point2 then
VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
end
elseif AccurateHandPosition then
LocalPositioning = HandPosition
end
local Parent = RightHandGrip.Parent
RightHandGrip.C1 = CFrame.new()
RightHandGrip.C0 = RightHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
RightHandGrip.Parent = nil
RightHandGrip.Parent = Parent
--
local EquippedTool = GetExtraTool()
if EquippedTool and EquippedTool:FindFirstChild("Handle") then
local EquippedGrip = GetGripForHandle(EquippedTool.Handle)
local Parent = EquippedGrip.Parent
local ArmBaseCFrame = ArmBase.CFrame
if ArmBase.Name == "Right Arm" then
ArmBaseCFrame = ArmBaseCFrame
end
EquippedGrip.C1 = EquippedTool.Grip
EquippedGrip.C0 = EquippedGrip.C0:Lerp(ArmBaseCFrame:ToObjectSpace(LocalPositioning), Smoothness)
EquippedGrip.Parent = nil
EquippedGrip.Parent = Parent
end
elseif LeftHandle and UserCFrame == Enum.UserCFrame.LeftHand and AccessorySettings.LeftArm then
local HandPosition = Positioning
if not LeftHandGrip or not LeftHandGrip.Parent then
LeftHandGrip = CreateRightGrip(LeftHandle)
end
if AccurateHandPosition then
HandPosition = HandPosition * CFrame.new(0, 0, 1)
end
if not VRReady then
HandPosition =
VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5) *
AccessorySettings.LimbOffset
--warn("Setting HandPosition to hands")
if Point1 then
VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
end
end
local Parent = LeftHandGrip.Parent
LeftHandGrip.C1 = CFrame.new()
LeftHandGrip.C0 = LeftHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
LeftHandGrip.Parent = nil
LeftHandGrip.Parent = Parent
end
end
if RagdollEnabled then
if UserCFrame == Enum.UserCFrame.Head and RagdollHeadMovement then
MoveHead(Positioning)
elseif UserCFrame == Enum.UserCFrame.RightHand then
local Positioning = Positioning
if not VRReady then
Positioning = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5)
elseif AccurateHandPosition then
Positioning = Positioning * CFrame.new(0, 0, 1)
end
if VRReady then
Positioning = Positioning * AccessorySettings.LimbOffset
end
MoveRightArm(Positioning)
if Point2 then
VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
end
elseif UserCFrame == Enum.UserCFrame.LeftHand then
local Positioning = Positioning
if not VRReady then
Positioning = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5)
elseif AccurateHandPosition then
Positioning = Positioning * CFrame.new(0, 0, 1)
end
if VRReady then
Positioning = Positioning * AccessorySettings.LimbOffset
end
MoveLeftArm(Positioning)
if Point1 then
VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
end
end
end
if UserCFrame == Enum.UserCFrame.Head then
VirtualRig.Head.CFrame = Positioning
elseif UserCFrame == Enum.UserCFrame.RightHand and VRReady then
VirtualRig.RightHand.CFrame = Positioning
elseif UserCFrame == Enum.UserCFrame.LeftHand and VRReady then
VirtualRig.LeftHand.CFrame = Positioning
end
if not VRReady and VirtualRig.LeftHand.Anchored then
VirtualRig.RightHand.Anchored = false
VirtualRig.LeftHand.Anchored = false
elseif VRReady and not VirtualRig.LeftHand.Anchored then
VirtualRig.RightHand.Anchored = true
VirtualRig.LeftHand.Anchored = true
end
end
local CFrameChanged = VRService.UserCFrameChanged:Connect(OnUserCFrameChanged)
local OnStepped =
RunService.Stepped:Connect(
function()
for _, Part in pairs(VirtualRig:GetChildren()) do
if Part:IsA("BasePart") then
Part.CanCollide = false
end
end
if RagdollEnabled then
for _, Part in pairs(Character:GetChildren()) do
if Part:IsA("BasePart") then
Part.CanCollide = false
end
end
end
if NoCollision then
for _, Player in pairs(Players:GetPlayers()) do
if Player ~= Client and Player.Character then
local Descendants = Player.Character:GetDescendants()
for i = 1, #Descendants do
local Part = Descendants[i]
if Part:IsA("BasePart") then
Part.CanCollide = false
Part.Velocity = Vector3.new()
Part.RotVelocity = Vector3.new()
end
end
end
end
end
end
)
local OnRenderStepped =
RunService.Stepped:Connect(
function()
Camera.CameraSubject = VirtualBody:FindFirstChildOfClass("Humanoid")
if RagdollEnabled then
Character.HumanoidRootPart.CFrame = VirtualRig.UpperTorso.CFrame
--Character.HumanoidRootPart.Velocity = Vector3.new(0, 0, 0)
end
if not VRReady then
OnUserCFrameChanged(Enum.UserCFrame.Head, CFrame.new(0, 0, 0))
OnUserCFrameChanged(Enum.UserCFrame.RightHand, CFrame.new(0, 0, 0), true)
OnUserCFrameChanged(Enum.UserCFrame.LeftHand, CFrame.new(0, 0, 0), true)
end
end
)
spawn(
function()
while Character and Character.Parent do
FootYield()
UpdateFooting()
end