View difference between Paste ID: 4DhMA89x and h3yGZnde
SHOW: | | - or go back to the newest paste.
1
-- RECLOVR V4
2
3
--[[
4
CREDITS TO: Emper, MyWorld
5
For helping out with the Net
6
7
CREATED BY: spectrumglitcher (Sticks)
8
yes. this is a very watered down ver of wyvern reanimate
9
10
11
11263254795,11159410305,12344545199,12344591101
12
use any hat that covers the torso
13
14
]]
15
16
-- OPTIONS
17
18
local FlingOptions = {
19
	FlingEnabled = false; -- THIS ISN'T GOING TO WORK WITH RECLOVR!
20
	ScanFling = false; -- THIS ISN'T GOING TO WORK WITH RECLOVR!
21
	ScanFlingRange = 5; -- THIS ISN'T GOING TO WORK WITH RECLOVR!
22
}
23
local NetOptions = {
24
	DefaultYVelocity=25.1;	-- 25.1
25
	AntiJitterValue=10; -- 10
26
}
27
local MiscOptions = {
28
	DeathLocationSpawn = true;
29
	InstantRespawn = true; -- Works in certain games
30
}
31
32
33
local vrs=game:FindFirstChildOfClass("VRService")
34
local Cam=workspace.CurrentCamera
35
local Pl=game.Players.LocalPlayer
36
local Ch=Pl.Character
37
local Rs=game["Run Service"]
38
local M=Pl:GetMouse()
39
local Fling = {}
40
local AllConections = {}
41
local HeartbeatTable = {}
42
local camcon0, camcon1 = nil, nil
43
local CurrentCameraCFrame=Cam.CFrame
44
local cf=CFrame.new
45
local v3=Vector3.new
46
local sin=math.sin
47
local angles=CFrame.Angles
48
local rad=math.rad
49
local cl=os.clock
50
local rand=math.random
51
52
Ch.Archivable=true
53
local FC=Ch:Clone()
54
Ch.Archivable=false
55
FC.Parent=workspace.Terrain
56
local hrp=FC:WaitForChild("HumanoidRootPart")
57
local hum=FC:FindFirstChildOfClass("Humanoid")
58
59
for _, x in pairs(FC:GetDescendants()) do
60
	if x:IsA("BasePart")  then
61
		x.CanCollide=false x.CanTouch=false x.CanQuery=false x.Transparency=1
62
	end
63
	if x.Parent.ClassName == "Accessory"  and x:IsA("BasePart") then
64
		x.Transparency=0.75
65
	end
66
end
67
FC.Head.face.Transparency=1
68
69
70
71
function Weld(P0,P1,C0)
72
	local w=Instance.new("Weld",P0)
73
	w.Part0=P0
74
	w.Part1=P1
75
	w.C0=C0
76
	return w
77
end
78
79
function Announce(Message, Time)
80
	game:FindFirstChildOfClass("StarterGui"):SetCore("SendNotification", {
81
		Title = "Notify";
82
		Text = Message;
83
		Icon = "rbxassetid://0";
84
		Duration = Time;
85
	})
86
end
87
88
function GetPartFromIDs(TX,MS)
89
	local ReanHandle=nil
90
	for _, x in pairs(FC:GetDescendants()) do
91
		if x:IsA("SpecialMesh") then
92
			if x.MeshId == MS and x.TextureId == TX then
93
				ReanHandle=x.Parent
94
			end
95
		end
96
	end
97
	return ReanHandle
98
end
99
100
function Reanimate(Character)
101
	--Character:FindFirstChildOfClass("Humanoid").RootPart.CFrame=FC:FindFirstChildOfClass("Humanoid").RootPart.CFrame*cf(rand(-30,30),rand(-30,30),rand(-30,30)
102
	Character:FindFirstChildOfClass("Humanoid").RootPart.CFrame=hrp.CFrame*cf(rand(-10, 10), 0, rand(-10, 10)) * angles(rad(90), 0 , 0)
103
	for _, x in pairs(Character:GetChildren()) do
104
		if x:IsA("BasePart")  then
105
			x.CanCollide=false x.CanTouch=false x.CanQuery=false x.Transparency=1
106
			x.Massless=true 
107
		end
108
		if x:IsA("Accessory") and x:FindFirstChildOfClass("Part") then
109
			local Handle=x:WaitForChild("Handle")
110
			local SpecialMesh = Handle:FindFirstChildOfClass("SpecialMesh")
111
			local TX,MS = SpecialMesh.TextureId, SpecialMesh.MeshId
112
			local ReanHandle=nil
113
			Handle:BreakJoints()
114
			for _, x in pairs(FC:GetDescendants()) do
115
				if x:IsA("SpecialMesh") then
116
					if x.MeshId == MS and x.TextureId == TX then
117
						ReanHandle=x.Parent
118
					end
119
				end
120
			end
121
			if ReanHandle ~= nil then
122
				local Cone=nil
123
				Cone=Rs.Heartbeat:Connect(function()
124
					if (Handle and ReanHandle) ~= nil then
125
						if Handle.ReceiveAge == 0 then
126
							Handle.RotVelocity =  v3(sin(cl()*15), sin(cl()*15+1.047), sin(cl()*15+2.094))
127
							Handle.Velocity=v3(0,NetOptions.DefaultYVelocity,0)+ReanHandle.Velocity*v3(NetOptions.AntiJitterValue,0,NetOptions.AntiJitterValue)
128
							Handle.CanCollide=false
129
							Handle.CFrame = ReanHandle.CFrame + v3(0.0015*sin(cl()*15), 0.0015*sin(cl()*15+1.047), 0.0015*sin(cl()*15+2.094))
130
							--Handle.CFrame = ReanHandle.CFrame + v3(0.003*sin(cl()*15), 0.003*sin(cl()*15+1.047), 0.003*sin(cl()*15+2.094))
131
						end
132
						--Handle.CFrame= ReanHandle.CFrame + v3(0.02*sin(cl()*15), 0.02*sin(cl()*15+1.047), 0.02*sin(cl()*15+2.094))
133
					end
134
				end)
135
				table.insert(HeartbeatTable, Cone)
136
			end
137
		end
138
	end
139
	Character:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Dead,true)
140
	Character:FindFirstChildOfClass("Humanoid").Health=0
141
end
142
143
Ch:FindFirstChildOfClass("Humanoid").RootPart.CFrame=hrp.CFrame*cf(rand(-10, 10), 0, rand(-10, 10)) * angles(rad(90), 0 , 0)
144
task.wait(0.025)
145
Reanimate(Ch)
146
Pl.Character=FC
147
workspace.CurrentCamera.CameraSubject=FC
148
local ReanCon = Pl.CharacterAdded:Connect(function(MOD)
149
	if MOD ~= FC then
150
		Cam.CameraSubject=hum
151
		task.spawn(function()
152
			if vrs.VREnabled == false then
153
				Cam:GetPropertyChangedSignal("CFrame"):Wait()
154
				Cam.CFrame = CurrentCameraCFrame
155
			end
156
		end)
157
		for _, x in pairs(MOD:GetDescendants()) do
158
			if x:IsA("BasePart") and x.Parent.ClassName ~= "Accessory" then
159
				x.Size=v3(0.001,0.001,0.001)
160
				x.CanCollide=false
161
				x.Velocity=v3(0,0,0)
162
			end
163
		end
164
		for _, x in pairs(HeartbeatTable) do
165
			if x then
166
				x:Disconnect()
167
				x=nil
168
			end
169
		end
170
		MOD:WaitForChild("Humanoid")
171
		task.wait()
172
		Cam.CameraSubject=hum
173
		task.spawn(function()
174
			Cam:GetPropertyChangedSignal("CFrame"):Wait()
175
			Cam.CFrame = CurrentCameraCFrame
176
		end)
177
		Pl.Character=FC
178
		Ch=MOD
179
		local Root=MOD:WaitForChild("HumanoidRootPart")
180
		local PepperStepper = Rs.RenderStepped:Connect(function()
181
			for _, x in pairs(MOD:GetDescendants()) do
182
				if x:IsA("BasePart")  then
183
					x.Size=v3(0.001,0.001,0.001)
184
					x.CanCollide=false x.CanTouch=false x.CanQuery=false
185
					x.Velocity=v3(0,0,0) x.Transparency=1
186
				end
187
			end
188
		end)
189
		for _, x in pairs(MOD:GetChildren()) do
190
			if x:IsA("BasePart") then
191
				x.CanCollide=false
192
				x.CFrame=hrp.CFrame
193
				x.Velocity=v3(0,0,0)
194
			end
195
			if x:IsA("ForceField") then
196
				x:Destroy()
197
			end
198
		end
199
		if FlingOptions.FlingEnabled == true then
200
			for _, x in pairs(Fling) do
201
				if x:IsA("Humanoid") and x.Parent ~= nil and x ~= nil then
202
					local hl=x.Parent:FindFirstChildOfClass("Highlight")
203
					if hl then
204
						hl:Destroy()
205
					end
206
					local XRoot=x.RootPart
207
					for i=1, 50 do
208
						if x then
209
							for _, x in pairs(MOD:GetDescendants()) do
210
								if x:IsA("BasePart") then
211
									x.Size=v3(0.001,0.001,0.001)
212
								end
213
							end
214
							if x.RootPart ~= nil then
215
								if Root.CFrame.Y > workspace.FallenPartsDestroyHeight * 200  and x.RootPart.Velocity.Magnitude < x.WalkSpeed * x.JumpHeight then
216
									Rs.Heartbeat:Wait()
217
									if x.RootPart ~= nil then
218
										if x.RootPart.Velocity.Magnitude > x.WalkSpeed - 2 then
219
											Root.RotVelocity=v3(8500, 6500, 8500) 
220
											Root.CFrame=XRoot.CFrame*cf(rand(-x.WalkSpeed / 4, x.WalkSpeed / 4),rand(-x.WalkSpeed / 4, x.WalkSpeed / 4),rand(-x.WalkSpeed / 4, x.WalkSpeed / 4)) + v3(0.004*sin(cl()*15), 0.004*sin(cl()*15+1.047), 0.004*sin(cl()*15+2.094))
221
										else
222
											Root.RotVelocity=v3(8500, 6500, 8500)
223
											Root.CFrame=x.RootPart.CFrame + v3(0.004*sin(cl()*15), 0.004*sin(cl()*15+1.047), 0.004*sin(cl()*15+2.094))
224
										end
225
									end
226
								else
227
									Root.CFrame=hrp.CFrame*cf(0, 5, 0)
228
									Root.Velocity=v3(0,0,0)
229
									Root.RotVelocity=v3(0,0,0)
230
								end
231
							end
232
						end
233
					end
234
				end
235
			end
236
			if Root.Velocity.Magnitude > 150 then
237
				for i=1, 20 do
238
					Rs.RenderStepped:Wait()
239
					Root.CFrame=hrp.CFrame*cf(0, 5, 0)
240
					Root.Velocity=v3(0,0,0)
241
					Root.RotVelocity=v3(0,0,0)
242
				end
243
			end
244
		end
245
		table.clear(Fling)
246
		Root.CFrame=hrp.CFrame*cf(rand(-10, 10), 0, rand(-10, 10)) * angles(rad(90), 0 , 0)
247
		task.wait(0.025)
248
		Reanimate(MOD)
249
		PepperStepper:Disconnect()
250
		PepperStepper=nil
251
		wait(game.Players.RespawnTime-0.000001)
252
		CurrentCameraCFrame = Cam.CFrame
253
	end
254
end)
255
256
257
--  | made by 0866!!!!!!! and abacaxl!!!!!!!!
258
--  | tysm unverified
259
--  | tutorial and info: https://docs.google.com/document/d/16gb1NGq-ajBO55EgPhFBVq1DrpMdpk2qVPMaCpWrI5c/edit?usp=sharing
260
261
--  | should be functional for non-VR users, rightclick/leftclick = point right/left arm, may perform worse
262
--  | things you can do:
263
-- use tools and the likes (not functional with RagdollEnabled)
264
-- move and interact with the luxury of a full body (no leg tracking, feet auto place)
265
-- interact with things as a robloxian, accurate sizing and full body allows for full immersion
266
-- play as your own roblox character by enabling RagdollEnabled (R6 only, RagdollHeadMovement adds an extra 10 seconds to script startup)
267
-- move & teleport accurately by pointing your right hand and holding-releasing Y or B
268
-- view nearby players chatting & view nearby characters including yourself in the bottom right, good for recording videos
269
-- total customizability over what you appear as (Ragdoll disabled only)
270
271
--  | this version will likely be patched by roblox soon, we will be rewriting it to be worth selling long after this release!
272
273
--|| Controls:
274
275
-- [ R2 ]	- Sprint
276
-- [ L2 ]	- Crouch
277
-- [ L2 TAP ]	- Chat HUD
278
279
-- [ Y ]	- Point Walk		-- movement joystick works -- may or may not be mixed up with the Teleport button
280
-- [ B ]	- Point Teleport	-- may or may not be mixed up with the Walk button
281
-- [ X ]	- RagdollEnabled die
282
283
-- [ C ]	- Non-VR Teleport
284
-- [ LSHIFT ]	- Non-VR Sprint
285
-- [ LCTRL ]	- Non-VR Crouch
286
287
-- Default Roblox VR controls are included
288
289
--|| Settings:
290
291
local StudsOffset = 0.1 -- Character height offset (make negative if you're too high)
292
local Smoothness = 0.3 -- Character interpolation (0.1 - 1 = smooth - rigid)
293
294
local AnchorCharacter = true -- Prevent physics from causing inconsistencies (Keep this on for accurate tool positioning)
295
local HideCharacter = false -- Hide character on a faraway platform
296
local NoCollision = true -- Disable collision with nearby players
297
298
local ChatEnabled = true -- See chat on your left hand in-game (Toggle with the crouch button lol)
299
local ChatLocalRange = 70 -- Local chat range
300
301
local ViewportEnabled = true -- View yourself and nearby players in a frame
302
local ViewportRange = 30 -- Maximum distance players are updated
303
304
local RagdollEnabled = false -- Use your character instead of hats (NetworkOwner vulnerability)
305
local RagdollHeadMovement = true -- Move your head separately from your body (+9 second wait)
306
307
local AutoRun = false -- Rerun script on respawn
308
local AutoRespawn = true -- Reset when your virtual body dies
309
310
local WearAllAccessories = true -- Use all leftover hats for the head
311
local AccurateHandPosition = false -- Position your Roblox hands according to your real hands
312
313
local c = game:FindFirstChildOfClass("Players").LocalPlayer.Character
314
c.InternationalFedora.Name = "1"
315
c.InternationalFedora.Name = "2"
316
c.InternationalFedora.Name = "3"
317
c.InternationalFedora.Name = "4"
318
319
local AccessorySettings = {
320
    LeftArm        = "1"; -- Name of hat used as this limb
321
    RightArm    = "2"; -- Name of hat used as this limb
322
    LeftLeg        = "3"; -- Name of hat used as this limb
323
    RightLeg    = "4"; -- Name of hat used as this limb
324-
    Torso        = "MeshPartAccessory"; -- Name of hat used as this limb
324+
    Torso        = "Front"; -- Name of hat used as this limb
325
    Head        = true; -- Are extra hats assumed to be worn?
326
327
    BlockArms    = true; -- Remove accessory meshes of this limb
328
    BlockLegs    = true; -- Remove accessory meshes of this limb
329
    BlockTorso    = true; -- Remove accessory meshes of this limb
330
331
    LimbOffset    = CFrame.Angles(math.rad(-120), 0, 0); -- Don't touch
332
}
333
334
local FootPlacementSettings = {
335
	RightOffset = Vector3.new(.5, 0, 0),
336
	LeftOffset = Vector3.new(-.5, 0, 0),
337
}
338
339
--|| Script:
340
341
local Script = nil;
342
local Pointer = nil;
343
344
-- My coding style changed throughout this a lot lol
345
346
Script = function()
347
348
--[[
349
	Variablesa
350
--]]
351
352
	local Players = game:GetService("Players")
353
	local Client = Players.LocalPlayer
354
	local Character = Client.Character or Client.CharacterAdded:Wait()
355
	local WeldBase = Character:WaitForChild("HumanoidRootPart")
356
	local ArmBase = Character:FindFirstChild("RightHand") or Character:FindFirstChild("Right Arm") or WeldBase
357
	local Backpack = Client:WaitForChild("Backpack")
358
	local Mouse = Client:GetMouse()
359
360
	local Camera = workspace.CurrentCamera
361
362
	local VRService = game:GetService("VRService")
363
	local VRReady = VRService.VREnabled
364
365
	local UserInputService = game:GetService("UserInputService")
366
	local RunService = game:GetService("RunService")
367
	local HttpService = game:GetService("HttpService")
368
	local StarterGui = game:GetService("StarterGui")	
369
370
	local HeadAccessories = {};
371
	local UsedAccessories = {};
372
373
	local Pointer = false;
374
	local Point1 = false;
375
	local Point2 = false;
376
377
	local VirtualRig = game:GetObjects("rbxassetid://4468539481")[1]
378
	local VirtualBody = game:GetObjects("rbxassetid://4464983829")[1]
379
380
	local Anchor = Instance.new("Part")
381
382
	Anchor.Anchored = true
383
	Anchor.Transparency = 1
384
	Anchor.CanCollide = false
385
	Anchor.Parent = workspace
386
387
	if RagdollEnabled then
388
		if script:FindFirstChild("Network") then
389
			Network = require(script.Network)
390
		else
391
			Network = loadstring(game:HttpGet("https://pastebin.com/raw/bJms9qqM", true))()
392
		end
393
		Network:Claim();
394
	end
395
396
	StarterGui:SetCore("VRLaserPointerMode", 3)
397
398
--[[
399
	Character Protection
400
--]]
401
402
	local CharacterCFrame = WeldBase.CFrame
403
404
	if not RagdollEnabled then
405
		Character.Humanoid.AnimationPlayed:Connect(function(Animation)
406
			Animation:Stop()
407
		end)
408
409
		for _, Track in next, Character.Humanoid:GetPlayingAnimationTracks() do
410
			Track:Stop()
411
		end
412
413
		wait(.5)
414
415
		if HideCharacter then
416
			local Platform = Instance.new("Part")
417
418
			Platform.Anchored = true
419
			Platform.Size = Vector3.new(100, 5, 100)
420
			Platform.CFrame = CFrame.new(0, 10000, 0)
421
			Platform.Transparency = 1
422
			Platform.Parent = workspace
423
424
			Character:MoveTo(Platform.Position + Vector3.new(0, 5, 0))
425
426
			wait(.5)
427
		end
428
429
		if AnchorCharacter then
430
			for _, Part in pairs(Character:GetChildren()) do
431
				if Part:IsA("BasePart") then
432
					Part.Anchored = true
433
				end
434
			end
435
		end
436
	end
437
438
--[[
439
	Functions
440
--]]
441
442
	function Tween(Object, Style, Direction, Time, Goal)
443
		local tweenInfo = TweenInfo.new(Time, Enum.EasingStyle[Style], Enum.EasingDirection[Direction])
444
		local tween = game:GetService("TweenService"):Create(Object, tweenInfo, Goal)
445
446
		tween.Completed:Connect(function()
447
			tween:Destroy()
448
		end)
449
450
		tween:Play()
451
452
		return tween
453
	end
454
455
	local function GetMotorForLimb(Limb)
456
		for _, Motor in next, Character:GetDescendants() do
457
			if Motor:IsA("Motor6D") and Motor.Part1 == Limb then
458
				return Motor
459
			end
460
		end
461
	end
462
463
	local function CreateAlignment(Limb, Part0)
464
		local Attachment0 = Instance.new("Attachment", Part0 or Anchor)
465
		local Attachment1 = Instance.new("Attachment", Limb)
466
467
		local Orientation = Instance.new("AlignOrientation")
468
		local Position = Instance.new("AlignPosition")
469
470
		Orientation.Attachment0 = Attachment1
471
		Orientation.Attachment1 = Attachment0
472
		Orientation.RigidityEnabled = false
473
		Orientation.MaxTorque = 20000
474
		Orientation.Responsiveness = 40
475
		Orientation.Parent = Character.HumanoidRootPart
476
477
		Position.Attachment0 = Attachment1
478
		Position.Attachment1 = Attachment0
479
		Position.RigidityEnabled = false
480
		Position.MaxForce = 40000
481
		Position.Responsiveness = 40
482
		Position.Parent = Character.HumanoidRootPart
483
484
		Limb.Massless = false
485
486
		local Motor = GetMotorForLimb(Limb)
487
		if Motor then
488
			Motor:Destroy()
489
		end
490
491
		return function(CF, Local)
492
			if Local then
493
				Attachment0.CFrame = CF
494
			else
495
				Attachment0.WorldCFrame = CF
496
			end
497
		end;
498
	end
499
500
	local function GetExtraTool()
501
		for _, Tool in next, Character:GetChildren() do
502
			if Tool:IsA("Tool") and not Tool.Name:match("LIMB_TOOL") then
503
				return Tool
504
			end
505
		end
506
	end
507
508
	local function GetGripForHandle(Handle)
509
		for _, Weld in next, Character:GetDescendants() do
510
			if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
511
				return Weld
512
			end
513
		end
514
515
		wait(.2)
516
517
		for _, Weld in next, Character:GetDescendants() do
518
			if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
519
				return Weld
520
			end
521
		end
522
	end
523
524
	local function CreateRightGrip(Handle)
525
		local RightGrip = Instance.new("Weld")
526
527
		RightGrip.Name = "RightGrip"
528
		RightGrip.Part1 = Handle
529
		RightGrip.Part0 = WeldBase
530
		RightGrip.Parent = WeldBase
531
532
		return RightGrip
533
	end
534
535
	local function CreateAccessory(Accessory, DeleteMeshes)
536
		if not Accessory then
537
			return
538
		end
539
540
		local HatAttachment = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
541
		local HeadAttachment = VirtualRig:FindFirstChild(HatAttachment.Name, true)
542
		local BasePart = HeadAttachment.Parent
543
544
		local HatAtt = HatAttachment.CFrame
545
		local HeadAtt = HeadAttachment.CFrame
546
547
		if DeleteMeshes then
548
			if Accessory.Handle:FindFirstChild("Mesh") then
549
				Accessory.Handle.Mesh:Destroy()
550
			end
551
		end
552
553
		wait()
554
555
		local Handle = Accessory:WaitForChild("Handle")
556
557
		if Handle:FindFirstChildWhichIsA("Weld", true) then
558
			Handle:FindFirstChildWhichIsA("Weld", true):Destroy()
559
			Handle:BreakJoints()
560
		else
561
			Handle:BreakJoints()
562
		end
563
564
		Handle.Massless = true
565
		Handle.Transparency = 0.5
566
567
		UsedAccessories[Accessory] = true
568
569
		local RightGrip = CreateRightGrip(Handle)
570
571
		wait()
572
573
		for _, Object in pairs(Handle:GetDescendants()) do
574
			if not Object:IsA("BasePart") then
575
				pcall(function()
576
					Object.Transparency = 1
577
				end)
578
579
				pcall(function()
580
					Object.Enabled = false
581
				end)
582
			end
583
		end
584
585
		return Handle, RightGrip, HatAtt, HeadAtt, BasePart;
586
	end
587
588
	local function GetHeadAccessories()
589
		for _, Accessory in next, Character:GetChildren() do
590
			if Accessory:IsA("Accessory") and not UsedAccessories[Accessory] then
591
				local Handle, RightGrip, HatAtt, HeadAtt, BasePart = CreateAccessory(Accessory)
592
593
				table.insert(HeadAccessories, {Handle, RightGrip, HatAtt, HeadAtt, BasePart})
594
595
				do
596
					Handle.Transparency = 1
597
				end
598
599
				if not WearAllAccessories then
600
					break
601
				end
602
			end
603
		end
604
	end
605
606
--[[
607
	VR Replication Setup
608
--]]
609
610
	if not RagdollEnabled then
611
		LeftHandle, LeftHandGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftArm), AccessorySettings.BlockArms)
612
		RightHandle, RightHandGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.RightArm), AccessorySettings.BlockArms)
613
		LeftHipHandle, LeftLegGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftLeg), AccessorySettings.BlockLegs)
614
		RightHipHandle, RightLegGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.RightLeg), AccessorySettings.BlockLegs)
615
		TorsoHandle, TorsoGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.Torso), AccessorySettings.BlockTorso)
616
		GetHeadAccessories()
617
618
	elseif RagdollEnabled then
619
		if RagdollHeadMovement then
620
			Permadeath()
621
			MoveHead = CreateAlignment(Character["Head"])
622
		end
623
624
		MoveRightArm = CreateAlignment(Character["Right Arm"])
625
		MoveLeftArm = CreateAlignment(Character["Left Arm"])
626
		MoveRightLeg = CreateAlignment(Character["Right Leg"])
627
		MoveLeftLeg = CreateAlignment(Character["Left Leg"])
628
		MoveTorso = CreateAlignment(Character["Torso"])
629
		MoveRoot = CreateAlignment(Character.HumanoidRootPart)
630
631
		if RagdollHeadMovement then
632
			for _, Accessory in next, Character:GetChildren() do
633
				if Accessory:IsA("Accessory") and Accessory:FindFirstChild("Handle") then
634
					local Attachment1 = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
635
					local Attachment0 = Character:FindFirstChild(tostring(Attachment1), true)
636
637
					local Orientation = Instance.new("AlignOrientation")
638
					local Position = Instance.new("AlignPosition")
639
640
					print(Attachment1, Attachment0, Accessory)
641
642
					Orientation.Attachment0 = Attachment1
643
					Orientation.Attachment1 = Attachment0
644
					Orientation.RigidityEnabled = false
645
					Orientation.ReactionTorqueEnabled = true
646
					Orientation.MaxTorque = 20000
647
					Orientation.Responsiveness = 40
648
					Orientation.Parent = Character.Head
649
650
					Position.Attachment0 = Attachment1
651
					Position.Attachment1 = Attachment0
652
					Position.RigidityEnabled = false
653
					Position.ReactionForceEnabled = true
654
					Position.MaxForce = 40000
655
					Position.Responsiveness = 40
656
					Position.Parent = Character.Head
657
				end
658
			end
659
		end
660
	end
661
662
--[[
663
	Movement
664
--]]
665
666
	VirtualRig.Name = "VirtualRig"
667
	VirtualRig.RightFoot.BodyPosition.Position = CharacterCFrame.p
668
	VirtualRig.LeftFoot.BodyPosition.Position = CharacterCFrame.p
669
	VirtualRig.Parent = workspace
670
	VirtualRig:SetPrimaryPartCFrame(CharacterCFrame)
671
672
	VirtualRig.Humanoid.Health = 0
673
	VirtualRig:BreakJoints()
674
	--
675
676
	VirtualBody.Parent = workspace
677
	VirtualBody.Name = "VirtualBody"
678
	VirtualBody.Humanoid.WalkSpeed = 8
679
	VirtualBody.Humanoid.CameraOffset = Vector3.new(0, StudsOffset, 0)
680
	VirtualBody:SetPrimaryPartCFrame(CharacterCFrame)
681
682
	VirtualBody.Humanoid.Died:Connect(function()
683
		print("Virtual death")
684
		if AutoRespawn then
685
			Character:BreakJoints()
686
687
			if RagdollHeadMovement and RagdollEnabled then
688
				Network:Unclaim()
689
				Respawn()
690
			end
691
		end
692
	end)
693
	--
694
695
	Camera.CameraSubject = VirtualBody.Humanoid
696
697
	Character.Humanoid.WalkSpeed = 0
698
	Character.Humanoid.JumpPower = 1
699
700
	for _, Part in next, VirtualBody:GetChildren() do
701
		if Part:IsA("BasePart") then
702
			Part.Transparency = 1
703
		end
704
	end
705
706
	for _, Part in next, VirtualRig:GetChildren() do
707
		if Part:IsA("BasePart") then
708
			Part.Transparency = 1
709
		end
710
	end
711
712
	if not VRReady then
713
		VirtualRig.RightUpperArm.ShoulderConstraint.RigidityEnabled = true
714
		VirtualRig.LeftUpperArm.ShoulderConstraint.RigidityEnabled = true
715
	end
716
717
718
	local OnMoving = RunService.Stepped:Connect(function()
719
		local Direction = Character.Humanoid.MoveDirection
720
		local Start = VirtualBody.HumanoidRootPart.Position
721
		local Point = Start + Direction * 6
722
723
		local Gyro = VirtualBody.HumanoidRootPart:FindFirstChild("BodyGyro") or Instance.new("BodyGyro", VirtualBody.HumanoidRootPart)
724
725
		Gyro.MaxTorque = Vector3.new(0, 100000, 0)
726
		Gyro.CFrame = Camera:GetRenderCFrame() + Direction
727
728
		if Pointer.Beam.Enabled then 
729
			Point = Pointer.Target.WorldCFrame.p
730
		end
731
732
		VirtualBody.Humanoid:MoveTo(Point)
733
	end)
734
735
	Character.Humanoid.Jumping:Connect(function()
736
		VirtualBody.Humanoid.Jump = true
737
	end)
738
739
	UserInputService.JumpRequest:Connect(function()
740
		VirtualBody.Humanoid.Jump = true
741
	end)
742
743
--[[
744
	VR Replication
745
--]]
746
747
	if RagdollEnabled then
748
		for _, Part in pairs(Character:GetDescendants()) do
749
			if Part:IsA("BasePart") and Part.Name == "Handle" and Part.Parent:IsA("Accessory") then
750
				Part.LocalTransparencyModifier = 1
751
			elseif Part:IsA("BasePart") and Part.Transparency < 0.5 then
752
				Part.LocalTransparencyModifier = 0.5
753
			end
754
755
			if not Part:IsA("BasePart") and not Part:IsA("AlignPosition") and not Part:IsA("AlignOrientation") then
756
				pcall(function()
757
					Part.Transparency = 1
758
				end)
759
760
				pcall(function()
761
					Part.Enabled = false
762
				end)
763
			end
764
		end
765
	end
766
767
	local FootUpdateDebounce = tick()
768
	local function FloorRay(Part, Distance)
769
		local Position = Part.CFrame.p
770
		local Target = Position - Vector3.new(0, Distance, 0)
771
		local Line = Ray.new(Position, (Target - Position).Unit * Distance)
772
		local FloorPart, FloorPosition, FloorNormal =
773
			workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character})
774
		if FloorPart then
775
			return FloorPart, FloorPosition, FloorNormal, (FloorPosition - Position).Magnitude
776
		else
777
			return nil, Target, Vector3.new(), Distance
778
		end
779
	end
780
	local function Flatten(CF)
781
		local X, Y, Z = CF.X, CF.Y, CF.Z
782
		local LX, LZ = CF.lookVector.X, CF.lookVector.Z
783
		return CFrame.new(X, Y, Z) * CFrame.Angles(0, math.atan2(LX, LZ), 0)
784
	end
785
	local FootTurn = 1
786
	local function FootReady(Foot, Target)
787
		local MaxDist
788
		if Character.Humanoid.MoveDirection.Magnitude > 0 then
789
			MaxDist = .5
790
		else
791
			MaxDist = 1
792
		end
793
		local PastThreshold = (Foot.Position - Target.Position).Magnitude > MaxDist
794
		local PastTick = tick() - FootUpdateDebounce >= 2
795
		if PastThreshold or PastTick then
796
			FootUpdateDebounce = tick()
797
		end
798
		return PastThreshold or PastTick
799
	end
800
	local function FootYield()
801
		local RightFooting = VirtualRig.RightFoot.BodyPosition
802
		local LeftFooting = VirtualRig.LeftFoot.BodyPosition
803
		local LowerTorso = VirtualRig.LowerTorso
804
		local Yield = tick()
805
		repeat
806
			RunService.Stepped:Wait()
807
			if
808
				(LowerTorso.Position - RightFooting.Position).Y > 4 or
809
				(LowerTorso.Position - LeftFooting.Position).Y > 4 or
810
				((LowerTorso.Position - RightFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4 or
811
				((LowerTorso.Position - LeftFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4
812
			then
813
				break
814
			end
815
		until tick() - Yield >= .17
816
	end
817
	local function UpdateFooting()
818
		if not VirtualRig:FindFirstChild("LowerTorso") then
819
			wait()
820
			return
821
		end
822
		local Floor, FloorPosition, FloorNormal, Dist = FloorRay(VirtualRig.LowerTorso, 3)
823
		Dist = math.clamp(Dist, 0, 5)
824
		local FootTarget =
825
			VirtualRig.LowerTorso.CFrame * CFrame.new(FootPlacementSettings.RightOffset) - Vector3.new(0, Dist, 0) +
826
			Character.Humanoid.MoveDirection * (VirtualBody.Humanoid.WalkSpeed / 8) * 2
827
		if FootReady(VirtualRig.RightFoot, FootTarget) then
828
			VirtualRig.RightFoot.BodyPosition.Position = FootTarget.p
829
			VirtualRig.RightFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
830
		end
831
		FootYield()
832
		local FootTarget =
833
			VirtualRig.LowerTorso.CFrame * CFrame.new(FootPlacementSettings.LeftOffset) - Vector3.new(0, Dist, 0) +
834
			Character.Humanoid.MoveDirection * (VirtualBody.Humanoid.WalkSpeed / 8) * 2
835
		if FootReady(VirtualRig.LeftFoot, FootTarget) then
836
			VirtualRig.LeftFoot.BodyPosition.Position = FootTarget.p
837
			VirtualRig.LeftFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
838
		end
839
	end
840
	local function UpdateTorsoPosition()
841
		if not RagdollEnabled then
842
			if TorsoHandle then
843
				local Positioning = VirtualRig.UpperTorso.CFrame
844
				if not TorsoGrip or not TorsoGrip.Parent then
845
					TorsoGrip = CreateRightGrip(TorsoHandle)
846
				end
847
				local Parent = TorsoGrip.Parent
848
				TorsoGrip.C1 = CFrame.new()
849
				TorsoGrip.C0 =
850
					TorsoGrip.C0:Lerp(
851
						WeldBase.CFrame:ToObjectSpace(Positioning * CFrame.new(0, -0.25, 0) * AccessorySettings.LimbOffset),
852
						Smoothness
853
					)
854
				TorsoGrip.Parent = nil
855
				TorsoGrip.Parent = Parent
856
			end
857
		else
858
			local Positioning = VirtualRig.UpperTorso.CFrame
859
			MoveTorso(Positioning * CFrame.new(0, -0.25, 0))
860
			MoveRoot(Positioning * CFrame.new(0, -0.25, 0))
861
		end
862
	end
863
	local function UpdateLegPosition()
864
		if not RagdollEnabled then
865
			if RightHipHandle then
866
				local Positioning =
867
					VirtualRig.RightLowerLeg.CFrame:Lerp(VirtualRig.RightFoot.CFrame, 0.5) + Vector3.new(0, 0.5, 0)
868
				if not RightHipHandle or not RightHipHandle.Parent then
869
					RightLegGrip = CreateRightGrip(RightHipHandle)
870
				end
871
				local Parent = RightLegGrip.Parent
872
				RightLegGrip.C1 = CFrame.new()
873
				RightLegGrip.C0 =
874
					RightLegGrip.C0:Lerp(
875
						WeldBase.CFrame:ToObjectSpace(Positioning * angles(rad(90),rad(90),rad(0))),
876
						Smoothness
877
					)
878
				RightLegGrip.Parent = nil
879
				RightLegGrip.Parent = Parent
880
			end
881
			if LeftHipHandle then
882
				local Positioning =
883
					VirtualRig.LeftLowerLeg.CFrame:Lerp(VirtualRig.LeftFoot.CFrame, 0.5) + Vector3.new(0, 0.5, 0)
884
				if not LeftLegGrip or not LeftLegGrip.Parent then
885
					LeftLegGrip = CreateRightGrip(LeftHipHandle)
886
				end
887
				local Parent = LeftLegGrip.Parent
888
				LeftLegGrip.C1 = CFrame.new()
889
				LeftLegGrip.C0 =
890
					LeftLegGrip.C0:Lerp(
891
						WeldBase.CFrame:ToObjectSpace(Positioning * angles(rad(90),rad(90),rad(0))),
892
						Smoothness
893
					)
894
				LeftLegGrip.Parent = nil
895
				LeftLegGrip.Parent = Parent
896
			end
897
		else
898
			do
899
				local Positioning =
900
					VirtualRig.RightLowerLeg.CFrame:Lerp(VirtualRig.RightFoot.CFrame, 0.5) *
901
					CFrame.Angles(0, math.rad(180), 0) +
902
					Vector3.new(0, 0.5, 0)
903
				MoveRightLeg(Positioning)
904
			end
905
			do
906
				local Positioning =
907
					VirtualRig.LeftLowerLeg.CFrame:Lerp(VirtualRig.LeftFoot.CFrame, 0.5) *
908
					CFrame.Angles(0, math.rad(180), 0) +
909
					Vector3.new(0, 0.5, 0)
910
				MoveLeftLeg(Positioning)
911
			end
912
		end
913
	end
914
915
	warn("VRReady is", VRReady)
916
917
	local function OnUserCFrameChanged(UserCFrame, Positioning, IgnoreTorso)
918
		local Positioning = Camera.CFrame * Positioning
919
920
		if ((VRReady and UserCFrame == Enum.UserCFrame.Head) or not VRReady) and not IgnoreTorso then
921
			UpdateTorsoPosition()
922
			UpdateLegPosition()
923
		end
924
925
		if not RagdollEnabled then
926
			if UserCFrame == Enum.UserCFrame.Head and AccessorySettings.Head then
927
				for _, Table in next, HeadAccessories do
928
					local Handle, RightGrip, HatAtt, HeadAtt, BasePart = unpack(Table)
929
					local LocalPositioning = Positioning
930
931
					if not RightGrip or not RightGrip.Parent then
932
						RightGrip = CreateRightGrip(Handle)
933
						Table[2] = RightGrip
934
					end
935
936
					local Parent = RightGrip.Parent
937
938
					if BasePart then
939
						LocalPositioning = BasePart.CFrame * HeadAtt
940
					end
941
942
					RightGrip.C1 = HatAtt
943
					RightGrip.C0 = RightGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(LocalPositioning), Smoothness)
944
					RightGrip.Parent = nil
945
					RightGrip.Parent = Parent
946
				end
947
948
			elseif RightHandle and UserCFrame == Enum.UserCFrame.RightHand and AccessorySettings.RightArm then
949
				local HandPosition = Positioning
950
				local LocalPositioning = Positioning
951
952
				if not RightHandGrip or not RightHandGrip.Parent then
953
					RightHandGrip = CreateRightGrip(RightHandle)
954
				end
955
956
				if AccurateHandPosition then
957
					HandPosition = HandPosition * CFrame.new(0, 0, 1)
958
				else
959
					HandPosition = HandPosition * CFrame.new(0, 0, .5)
960
				end
961
962
				if not VRReady then
963
					local HeadRotation = Camera.CFrame - Camera.CFrame.p
964
965
					HandPosition = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5) * AccessorySettings.LimbOffset
966
967
					--LocalPositioning = (HeadRotation + (HandPosition * CFrame.new(0, 0, 1)).p) * CFrame.Angles(math.rad(-45), 0, 0)
968
					LocalPositioning = HandPosition * CFrame.new(0, 0, 1) * CFrame.Angles(math.rad(-180), 0, 0)
969
970
					if Point2 then
971
						VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
972
						VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * angles(rad(90),rad(0),rad(0))
973
					elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
974
						VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
975
					end
976
				elseif not AccurateHandPosition then
977
					LocalPositioning = HandPosition * CFrame.new(0, 0, -1)
978
				end
979
980
				local Parent = RightHandGrip.Parent
981
982
				RightHandGrip.C1 = CFrame.new()
983
				RightHandGrip.C0 = RightHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
984
				RightHandGrip.Parent = nil
985
				RightHandGrip.Parent = Parent
986
987
				--
988
989
				local EquippedTool = GetExtraTool()
990
991
				if EquippedTool and EquippedTool:FindFirstChild("Handle") then
992
					local EquippedGrip = GetGripForHandle(EquippedTool.Handle)
993
					local Parent = EquippedGrip.Parent
994
995
					local ArmBaseCFrame = ArmBase.CFrame
996
					if ArmBase.Name == "Right Arm" then
997
						ArmBaseCFrame = ArmBaseCFrame
998
					end
999
1000
					EquippedGrip.C1 = EquippedTool.Grip
1001
					EquippedGrip.C0 = EquippedGrip.C0:Lerp(ArmBaseCFrame:ToObjectSpace(LocalPositioning), Smoothness)
1002
					EquippedGrip.Parent = nil
1003
					EquippedGrip.Parent = Parent
1004
				end
1005
1006
			elseif LeftHandle and UserCFrame == Enum.UserCFrame.LeftHand and AccessorySettings.LeftArm then
1007
				local HandPosition = Positioning
1008
1009
				if not LeftHandGrip or not LeftHandGrip.Parent then
1010
					LeftHandGrip = CreateRightGrip(LeftHandle)
1011
				end
1012
1013
				if AccurateHandPosition then
1014
					HandPosition = HandPosition * CFrame.new(0, 0, 1)
1015
				else
1016
					HandPosition = HandPosition * CFrame.new(0, 0, .5)
1017
				end
1018
1019
				if not VRReady then
1020
					HandPosition = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5) * AccessorySettings.LimbOffset
1021
					--warn("Setting HandPosition to hands")
1022
					if Point1 then
1023
						VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
1024
						VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * angles(rad(90),rad(0),rad(0))
1025
					elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
1026
						VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
1027
					end
1028
				end
1029
1030
				local Parent = LeftHandGrip.Parent
1031
1032
				LeftHandGrip.C1 = CFrame.new()
1033
				LeftHandGrip.C0 = LeftHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
1034
				LeftHandGrip.Parent = nil
1035
				LeftHandGrip.Parent = Parent
1036
1037
			end
1038
		end
1039
1040
		if RagdollEnabled then
1041
			if UserCFrame == Enum.UserCFrame.Head and RagdollHeadMovement then
1042
				MoveHead(Positioning)
1043
			elseif UserCFrame == Enum.UserCFrame.RightHand then
1044
				local Positioning = Positioning
1045
1046
				if not VRReady then
1047
					Positioning = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5)
1048
				elseif AccurateHandPosition then
1049
					Positioning = Positioning * CFrame.new(0, 0, 1)
1050
				end
1051
1052
				if VRReady then
1053
					Positioning = Positioning * AccessorySettings.LimbOffset
1054
				end
1055
1056
				MoveRightArm(Positioning)
1057
1058
				if Point2 then
1059
					VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
1060
					VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame *  angles(rad(90),rad(0),rad(0))
1061
				elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
1062
					VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
1063
				end
1064
			elseif UserCFrame == Enum.UserCFrame.LeftHand then
1065
				local Positioning = Positioning
1066
1067
				if not VRReady then
1068
					Positioning = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5)
1069
				elseif AccurateHandPosition then
1070
					Positioning = Positioning * CFrame.new(0, 0, 1)
1071
				end
1072
1073
				if VRReady then
1074
					Positioning = Positioning * AccessorySettings.LimbOffset
1075
				end
1076
1077
				MoveLeftArm(Positioning)
1078
1079
				if Point1 then
1080
					VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
1081
					VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * angles(rad(90),rad(0),rad(0))
1082
				elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
1083
					VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
1084
				end
1085
			end
1086
		end
1087
1088
		if UserCFrame == Enum.UserCFrame.Head then
1089
			VirtualRig.Head.CFrame = Positioning
1090
			VirtualRig.HumanoidRootPart.CFrame = Positioning
1091
1092
		elseif UserCFrame == Enum.UserCFrame.RightHand and VRReady then
1093
			VirtualRig.RightHand.CFrame = Positioning
1094
1095
		elseif UserCFrame == Enum.UserCFrame.LeftHand and VRReady then
1096
			VirtualRig.LeftHand.CFrame = Positioning
1097
1098
		end
1099
1100
		if not VRReady and VirtualRig.LeftHand.Anchored then
1101
			VirtualRig.RightHand.Anchored = false
1102
			VirtualRig.LeftHand.Anchored = false
1103
		elseif VRReady and not VirtualRig.LeftHand.Anchored then
1104
			VirtualRig.RightHand.Anchored = true
1105
			VirtualRig.LeftHand.Anchored = true
1106
		end
1107
	end
1108
1109
	local CFrameChanged = VRService.UserCFrameChanged:Connect(OnUserCFrameChanged)
1110
1111
	local OnStepped = RunService.Stepped:Connect(function()
1112
		for _, Part in pairs(VirtualRig:GetChildren()) do
1113
			if Part:IsA("BasePart") then
1114
				Part.CanCollide = false
1115
			end
1116
		end
1117
1118
		if RagdollEnabled then
1119
			for _, Part in pairs(Character:GetChildren()) do
1120
				if Part:IsA("BasePart") then
1121
					Part.CanCollide = false
1122
				end
1123
			end
1124
		end
1125
1126
		if NoCollision then
1127
			for _, Player in pairs(Players:GetPlayers()) do
1128
				if Player ~= Client and Player.Character then
1129
					local Char = Player.Character
1130
					local Descendants = Player.Character:GetChildren()
1131
1132
					local IsClose, Part = false, Char.PrimaryPart or Char:FindFirstChild("Head") or Char:FindFirstChildWhichIsA("BasePart")
1133
					if Part and (Camera.CFrame.Position - Part.Position).Magnitude < 30 then
1134
						IsClose = true
1135
					end
1136
1137
					if IsClose then
1138
						for i = 1, #Descendants do
1139
							local Part = Descendants[i]
1140
							if Part:IsA("BasePart") then
1141
								Part.CanCollide = false
1142
								Part.Velocity = Vector3.new()
1143
								Part.RotVelocity = Vector3.new()
1144
							end
1145
						end
1146
					end
1147
				end
1148
			end
1149
		end
1150
	end)
1151
1152
	local OnRenderStepped = RunService.Stepped:Connect(function()
1153
		Camera.CameraSubject = VirtualBody.Humanoid
1154
1155
		if RagdollEnabled then
1156
			Character.HumanoidRootPart.CFrame = VirtualRig.UpperTorso.CFrame
1157
			Character.HumanoidRootPart.Velocity = Vector3.new(0, 0, 0)
1158
		end
1159
1160
		if not VRReady then
1161
			OnUserCFrameChanged(Enum.UserCFrame.Head, CFrame.new(0, 0, 0))
1162
1163
			OnUserCFrameChanged(Enum.UserCFrame.RightHand, CFrame.new(0, 0, 0), true)
1164
			OnUserCFrameChanged(Enum.UserCFrame.LeftHand, CFrame.new(0, 0, 0), true)
1165
		end
1166
	end)
1167
1168
	spawn(function()
1169
		while Character and Character.Parent do
1170
			FootYield()
1171
			UpdateFooting()
1172
		end
1173
	end)
1174
1175
--[[
1176
	Non-VR Support + VR Mechanics
1177
--]]
1178
1179
	local OnInput = UserInputService.InputBegan:Connect(function(Input, Processed)
1180
		if not Processed then
1181
			if Input.KeyCode == Enum.KeyCode.LeftControl or Input.KeyCode == Enum.KeyCode.ButtonL2 then
1182
				Tween(VirtualBody.Humanoid, "Elastic", "Out", 1, {
1183
					CameraOffset = Vector3.new(0, StudsOffset - 1.5, 0)
1184
				})
1185
			end
1186
1187
			if Input.KeyCode == Enum.KeyCode.X then
1188
				if RagdollEnabled and RagdollHeadMovement then
1189
					Network:Unclaim()
1190
					Respawn()
1191
				end
1192
			end
1193
1194
			if Input.KeyCode == Enum.KeyCode.C or Input.KeyCode == Enum.KeyCode.ButtonB then
1195
				Pointer.Beam.Enabled = true
1196
				Pointer.Target.ParticleEmitter.Enabled = true
1197
			elseif Input.KeyCode == Enum.KeyCode.ButtonY then
1198
				VirtualBody.Humanoid:MoveTo(Pointer.Target.WorldCFrame.p)
1199
1200
				Pointer.Beam.Enabled = true
1201
				Pointer.Target.ParticleEmitter.Enabled = true
1202
			end
1203
		end
1204
1205
		if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.ButtonR2 then
1206
			Tween(VirtualBody.Humanoid, "Sine", "Out", 1, {
1207
				WalkSpeed = 16
1208
			})
1209
		end
1210
1211
		if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton1 then
1212
			Point1 = true
1213
		end
1214
1215
		if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton2 then
1216
			Point2 = true
1217
		end
1218
1219
		if VRReady and Input.KeyCode == Enum.KeyCode.ButtonX then
1220
			--Character:BreakJoints()
1221
1222
			if RagdollEnabled and RagdollHeadMovement then
1223
				Character:BreakJoints()
1224
				Network:Unclaim()
1225
				Respawn()
1226
			end
1227
		end
1228
	end)
1229
1230
	local OnInputEnded = UserInputService.InputEnded:Connect(function(Input, Processed)
1231
		if not Processed then
1232
			if Input.KeyCode == Enum.KeyCode.LeftControl or Input.KeyCode == Enum.KeyCode.ButtonL2 then
1233
				Tween(VirtualBody.Humanoid, "Elastic", "Out", 1, {
1234
					CameraOffset = Vector3.new(0, StudsOffset, 0)
1235
				})
1236
			elseif Input.KeyCode == Enum.KeyCode.ButtonB or Input.KeyCode == Enum.KeyCode.C then
1237
				if Mouse.Target and (Mouse.Hit.p - Camera.CFrame.p).Magnitude < 1000 then
1238
					VirtualBody:MoveTo(Pointer.Target.WorldCFrame.p)
1239
					VirtualRig:SetPrimaryPartCFrame(Pointer.Target.WorldCFrame)
1240
					VirtualRig.RightFoot.BodyPosition.Position = Pointer.Target.WorldCFrame.p
1241
					VirtualRig.LeftFoot.BodyPosition.Position = Pointer.Target.WorldCFrame.p
1242
				end
1243
1244
				Pointer.Beam.Enabled = false
1245
				Pointer.Target.ParticleEmitter.Enabled = false
1246
			elseif Input.KeyCode == Enum.KeyCode.ButtonY then
1247
				VirtualBody.Humanoid:MoveTo(Pointer.Target.WorldCFrame.p)
1248
1249
				Pointer.Beam.Enabled = false
1250
				Pointer.Target.ParticleEmitter.Enabled = false
1251
			end
1252
		end
1253
1254
		if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.ButtonR2 then
1255
			Tween(VirtualBody.Humanoid, "Sine", "Out", 1, {
1256
				WalkSpeed = 8
1257
			})
1258
		end
1259
1260
		if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton1 then
1261
			Point1 = false
1262
		end
1263
1264
		if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton2 then
1265
			Point2 = false
1266
		end
1267
	end)
1268
1269
--[[
1270
	Proper Cleanup
1271
--]]
1272
1273
	local OnReset
1274
1275
	OnReset = Client.CharacterAdded:Connect(function()
1276
1277
	end)
1278
1279
	if ChatEnabled then
1280
		spawn(ChatHUDFunc)
1281
	end
1282
1283
	if ViewportEnabled then
1284
		spawn(ViewHUDFunc)
1285
	end
1286
1287
	do
1288
	--[[
1289
		Functions
1290
	--]]
1291
1292
		local Players = game:GetService("Players")
1293
		local Client = Players.LocalPlayer
1294
1295
		local VRService = game:GetService("VRService")
1296
		local VRReady = VRService.VREnabled
1297
1298
		local UserInputService = game:GetService("UserInputService")
1299
		local RunService = game:GetService("RunService")
1300
1301
		local Camera = workspace.CurrentCamera
1302
1303
	--[[
1304
		Code
1305
	--]]
1306
1307
		if VRReady or true then
1308
			Pointer = game:GetObjects("rbxassetid://4476173280")[1]
1309
1310
			Pointer.Parent = workspace
1311
			Pointer.Beam.Enabled = false
1312
			Pointer.Target.ParticleEmitter.Enabled = false
1313
1314
			local RenderStepped = RunService.RenderStepped:Connect(function()
1315
				if Pointer.Beam.Enabled then
1316
					local RightHand = Camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
1317
					local Target = RightHand * CFrame.new(0, 0, -10)
1318
1319
					local Line = Ray.new(RightHand.p, (Target.p - RightHand.p).Unit * 10000)
1320
					local Part, Position = workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character, Pointer})
1321
1322
					local Distance = (Position - RightHand.p).Magnitude
1323
1324
					Pointer.Target.Position = Vector3.new(0, 0, -Distance)
1325
					Pointer.CFrame = RightHand
1326
				end
1327
			end)
1328
1329
			local Input = UserInputService.InputBegan:Connect(function(Input)
1330
1331
			end)
1332
1333
			--
1334
1335
			local CharacterAdded
1336
1337
			CharacterAdded = Client.CharacterAdded:Connect(function()
1338
1339
			end)
1340
		else
1341
			return
1342
		end
1343
	end
1344
1345
end;
1346
1347
Permadeath = function()
1348
	local ch = game.Players.LocalPlayer.Character
1349
	local prt=Instance.new("Model", workspace)
1350
	local z1 =  Instance.new("Part", prt)
1351
	z1.Name="Torso"
1352
	z1.CanCollide = false
1353
	z1.Anchored = true
1354
	local z2  =Instance.new("Part", prt)
1355
	z2.Name="Head"
1356
	z2.Anchored = true
1357
	z2.CanCollide = false
1358
	local z3 =Instance.new("Humanoid", prt)
1359
	z3.Name="Humanoid"
1360
	z1.Position = Vector3.new(0,9999,0)
1361
	z2.Position = Vector3.new(0,9991,0)
1362
	game.Players.LocalPlayer.Character=prt
1363
	wait(5)
1364
	warn("50%")
1365
	game.Players.LocalPlayer.Character=ch
1366
	wait(6)
1367
	warn("100%")
1368
end;
1369
1370
Respawn = function()
1371
	local ch = game.Players.LocalPlayer.Character
1372
1373
	local prt=Instance.new("Model", workspace)
1374
	local z1 =  Instance.new("Part", prt)
1375
	z1.Name="Torso"
1376
	z1.CanCollide = false
1377
	z1.Anchored = true
1378
	local z2  =Instance.new("Part", prt)
1379
	z2.Name="Head"
1380
	z2.Anchored = true
1381
	z2.CanCollide = false
1382
	local z3 =Instance.new("Humanoid", prt)
1383
	z3.Name="Humanoid"
1384
	z1.Position = Vector3.new(0,9999,0)
1385
	z2.Position = Vector3.new(0,9991,0)
1386
	game.Players.LocalPlayer.Character=prt
1387
	wait(5)
1388
	game.Players.LocalPlayer.Character=ch
1389
end;
1390
1391
ChatHUDFunc = function()
1392
	--[[
1393
		Variables
1394
	--]]
1395
1396
	local UserInputService = game:GetService("UserInputService")
1397
	local RunService = game:GetService("RunService")
1398
1399
	local VRService = game:GetService("VRService")
1400
	local VRReady = VRService.VREnabled
1401
1402
	local Players = game:GetService("Players")
1403
	local Client = Players.LocalPlayer
1404
1405
	local ChatHUD = game:GetObjects("rbxassetid://4476067885")[1]
1406
	local GlobalFrame = ChatHUD.GlobalFrame
1407
	local Template = GlobalFrame.Template
1408
	local LocalFrame = ChatHUD.LocalFrame
1409
	local Global = ChatHUD.Global
1410
	local Local = ChatHUD.Local
1411
1412
	local Camera = workspace.CurrentCamera
1413
1414
	Template.Parent = nil
1415
	ChatHUD.Parent = game:GetService("CoreGui")
1416
1417
	--[[
1418
		Code
1419
	--]]
1420
1421
	local Highlight = Global.Frame.BackgroundColor3
1422
	local Deselected = Local.Frame.BackgroundColor3
1423
1424
	local OpenGlobalTab = function()
1425
		Global.Frame.BackgroundColor3 = Highlight
1426
		Local.Frame.BackgroundColor3 = Deselected
1427
1428
		Global.Font = Enum.Font.SourceSansBold
1429
		Local.Font = Enum.Font.SourceSans
1430
1431
		GlobalFrame.Visible = true
1432
		LocalFrame.Visible = false
1433
	end
1434
1435
	local OpenLocalTab = function()
1436
		Global.Frame.BackgroundColor3 = Deselected
1437
		Local.Frame.BackgroundColor3 = Highlight
1438
1439
		Global.Font = Enum.Font.SourceSans
1440
		Local.Font = Enum.Font.SourceSansBold
1441
1442
		GlobalFrame.Visible = false
1443
		LocalFrame.Visible = true
1444
	end
1445
1446
	Global.MouseButton1Down:Connect(OpenGlobalTab)
1447
	Local.MouseButton1Down:Connect(OpenLocalTab)
1448
	Global.MouseButton1Click:Connect(OpenGlobalTab)
1449
	Local.MouseButton1Click:Connect(OpenLocalTab)
1450
1451
	OpenLocalTab()
1452
1453
	--
1454
1455
	local function GetPlayerDistance(Sender)
1456
		if Sender.Character and Sender.Character:FindFirstChild("Head") then
1457
			return math.floor((Sender.Character.Head.Position - Camera:GetRenderCFrame().p).Magnitude + 0.5)
1458
		end
1459
	end
1460
1461
	local function NewGlobal(Message, Sender, Color)
1462
		local Frame = Template:Clone()
1463
1464
		Frame.Text = ("[%s]: %s"):format(Sender.Name, Message)
1465
		Frame.User.Text = ("[%s]:"):format(Sender.Name)
1466
		Frame.User.TextColor3 = Color
1467
		Frame.BackgroundColor3 = Color
1468
		Frame.Parent = GlobalFrame
1469
1470
		delay(60, function()
1471
			Frame:Destroy()
1472
		end)
1473
	end
1474
1475
	local function NewLocal(Message, Sender, Color, Dist)
1476
		local Frame = Template:Clone()
1477
1478
		Frame.Text = ("(%s) [%s]: %s"):format(tostring(Dist), Sender.Name, Message)
1479
		Frame.User.Text = ("(%s) [%s]:"):format(tostring(Dist), Sender.Name)
1480
		Frame.User.TextColor3 = Color
1481
		Frame.BackgroundColor3 = Color
1482
		Frame.Parent = LocalFrame
1483
1484
		delay(60, function()
1485
			Frame:Destroy()
1486
		end)
1487
	end
1488
1489
	local function OnNewChat(Message, Sender, Color)
1490
		if not ChatHUD or not ChatHUD.Parent then return end
1491
1492
		NewGlobal(Message, Sender, Color)
1493
1494
		local Distance = GetPlayerDistance(Sender)
1495
1496
		if Distance and Distance <= ChatLocalRange then
1497
			NewLocal(Message, Sender, Color, Distance)
1498
		end
1499
	end
1500
1501
	local function OnPlayerAdded(Player)
1502
		if not ChatHUD or not ChatHUD.Parent then return end
1503
1504
		local Color = BrickColor.Random().Color
1505
1506
		Player.Chatted:Connect(function(Message)
1507
			OnNewChat(Message, Player, Color)
1508
		end)
1509
	end
1510
1511
	Players.PlayerAdded:Connect(OnPlayerAdded)
1512
1513
	for _, Player in pairs(Players:GetPlayers()) do
1514
		OnPlayerAdded(Player)
1515
	end
1516
1517
	--
1518
1519
	local ChatPart = ChatHUD.Part
1520
1521
	ChatHUD.Adornee = ChatPart
1522
1523
	if VRReady then
1524
		ChatHUD.Parent = game:GetService("CoreGui")
1525
		ChatHUD.Enabled = true
1526
		ChatHUD.AlwaysOnTop = true
1527
1528
		local OnInput = UserInputService.InputBegan:Connect(function(Input, Processed)
1529
			if not Processed then
1530
				if Input.KeyCode == Enum.KeyCode.ButtonL2 then
1531
					ChatHUD.Enabled = not ChatHUD.Enabled
1532
				end
1533
			end
1534
		end)
1535
1536
		local RenderStepped = RunService.RenderStepped:Connect(function()
1537
			local LeftHand = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
1538
1539
			ChatPart.CFrame = Camera.CFrame * LeftHand
1540
		end)
1541
1542
		local CharacterAdded
1543
1544
		CharacterAdded = Client.CharacterAdded:Connect(function()
1545
1546
		end)
1547
	end
1548
1549
	wait(9e9)
1550
end;
1551
1552
ViewHUDFunc = function()
1553
	--[[
1554
		Variables
1555
	--]]
1556
1557
	local ViewportRange = ViewportRange or 32
1558
1559
	local UserInputService = game:GetService("UserInputService")
1560
	local RunService = game:GetService("RunService")
1561
1562
	local VRService = game:GetService("VRService")
1563
	local VRReady = VRService.VREnabled
1564
1565
	local Players = game:GetService("Players")
1566
	local Client = Players.LocalPlayer
1567
	local Mouse = Client:GetMouse()
1568
1569
	local Camera = workspace.CurrentCamera
1570
	local CameraPort = Camera.CFrame
1571
1572
	local ViewHUD = script:FindFirstChild("ViewHUD") or game:GetObjects("rbxassetid://4480405425")[1]
1573
	local Viewport = ViewHUD.Viewport
1574
	local Viewcam = Instance.new("Camera")
1575
	local ViewPart = ViewHUD.Part
1576
1577
	ViewHUD.Parent = game:GetService("CoreGui")
1578
1579
	Viewcam.Parent = Viewport
1580
	Viewcam.CameraType = Enum.CameraType.Scriptable
1581
	Viewport.CurrentCamera = Viewcam
1582
	Viewport.BackgroundTransparency = 1
1583
1584
	--[[
1585
		Code
1586
	--]]
1587
1588
	local function Clone(Character)
1589
		local Arc = Character.Archivable
1590
		local Clone;
1591
1592
		Character.Archivable = true
1593
		Clone = Character:Clone()
1594
		Character.Archivable = Arc
1595
1596
		return Clone
1597
	end
1598
1599
	local function GetPart(Name, Parent, Descendants)
1600
		for i = 1, #Descendants do
1601
			local Part = Descendants[i]
1602
1603
			if Part.Name == Name and Part.Parent.Name == Parent then
1604
				return Part
1605
			end
1606
		end
1607
	end
1608
	
1609
	local function CharacterAdded(Character)
1610
		if not ViewHUD or not ViewHUD.Parent then return end
1611
1612
		Character:WaitForChild("Head")
1613
		Character:WaitForChild("Humanoid")
1614
1615
		wait(0.15)
1616
1617
		local FakeChar = Clone(Character)
1618
		local TrueRoot = Character:FindFirstChild("HumanoidRootPart") or Character:FindFirstChild("Head")
1619
		local Root = FakeChar:FindFirstChild("HumanoidRootPart") or FakeChar:FindFirstChild("Head")
1620
		local RenderConnection;
1621
1622
		local Descendants = FakeChar:GetDescendants()
1623
		local RealDescendants = Character:GetDescendants()
1624
		local Correspondents = {};
1625
1626
		FakeChar.Humanoid.DisplayDistanceType = "None"
1627
1628
		for i = 1, #Descendants do
1629
			local Part = Descendants[i]
1630
			local Real = Part:IsA("BasePart") and GetPart(Part.Name, Part.Parent.Name, RealDescendants)
1631
1632
			if Part:IsA("BasePart") and Real then
1633
				Part.Anchored = true
1634
				Part:BreakJoints()
1635
1636
				if Part.Parent:IsA("Accessory") then
1637
					Part.Transparency = 0
1638
				end
1639
1640
				table.insert(Correspondents, {Part, Real})
1641
			end
1642
		end
1643
1644
		RenderConnection = RunService.RenderStepped:Connect(function()
1645
			if not Character or not Character.Parent then
1646
1647
1648
				return
1649
			end
1650
1651
			if (TrueRoot and (TrueRoot.Position - Camera.CFrame.p).Magnitude <= ViewportRange) or Player == Client or not TrueRoot then
1652
				for i = 1, #Correspondents do
1653
					local Part, Real = unpack(Correspondents[i])
1654
1655
					if Part and Real and Part.Parent and Real.Parent then
1656
						Part.CFrame = Real.CFrame
1657
					elseif Part.Parent and not Real.Parent then
1658
						Part:Destroy()
1659
					end
1660
				end
1661
			end
1662
		end)
1663
1664
		FakeChar.Parent = Viewcam
1665
	end
1666
	
1667
	local function OnPlayerAdded(Player)
1668
		if not ViewHUD or not ViewHUD.Parent then return end
1669
1670
		local function CharacterAdded(Character)
1671
			if not ViewHUD or not ViewHUD.Parent then return end
1672
1673
			Character:WaitForChild("Head")
1674
			Character:WaitForChild("Humanoid")
1675
1676
			wait(3)
1677
1678
			local FakeChar = Clone(Character)
1679
			local TrueRoot = Character:FindFirstChild("HumanoidRootPart") or Character:FindFirstChild("Head")
1680
			local Root = FakeChar:FindFirstChild("HumanoidRootPart") or FakeChar:FindFirstChild("Head")
1681
			local RenderConnection;
1682
1683
			local Descendants = FakeChar:GetDescendants()
1684
			local RealDescendants = Character:GetDescendants()
1685
			local Correspondents = {};
1686
1687
			FakeChar.Humanoid.DisplayDistanceType = "None"
1688
1689
			for i = 1, #Descendants do
1690
				local Part = Descendants[i]
1691
				local Real = Part:IsA("BasePart") and GetPart(Part.Name, Part.Parent.Name, RealDescendants)
1692
1693
				if Part:IsA("BasePart") and Real then
1694
					Part.Anchored = true
1695
					Part:BreakJoints()
1696
1697
					if Part.Parent:IsA("Accessory") then
1698
						Part.Transparency = 0
1699
					end
1700
1701
					table.insert(Correspondents, {Part, Real})
1702
				end
1703
			end
1704
1705
			RenderConnection = RunService.RenderStepped:Connect(function()
1706
				if not Character or not Character.Parent then
1707
1708
1709
					return
1710
				end
1711
1712
				if (TrueRoot and (TrueRoot.Position - Camera.CFrame.p).Magnitude <= ViewportRange) or Player == Client or not TrueRoot then
1713
					for i = 1, #Correspondents do
1714
						local Part, Real = unpack(Correspondents[i])
1715
1716
						if Part and Real and Part.Parent and Real.Parent then
1717
							Part.CFrame = Real.CFrame
1718
						elseif Part.Parent and not Real.Parent then
1719
							Part:Destroy()
1720
						end
1721
					end
1722
				end
1723
			end)
1724
1725
			FakeChar.Parent = Viewcam
1726
		end
1727
1728
		Player.CharacterAdded:Connect(CharacterAdded)
1729
1730
		if Player.Character then
1731
			spawn(function()
1732
				CharacterAdded(Player.Character)
1733
			end)
1734
		end
1735
	end
1736
1737
	local PlayerAdded = Players.PlayerAdded:Connect(OnPlayerAdded)
1738
1739
	for _, Player in pairs(Players:GetPlayers()) do
1740
		OnPlayerAdded(Player)
1741
	end
1742
1743
	ViewPart.Size = Vector3.new()
1744
1745
	if VRReady then
1746
		Viewport.Position = UDim2.new(.62, 0, .89, 0)
1747
		Viewport.Size = UDim2.new(.3, 0, .3, 0)
1748
		Viewport.AnchorPoint = Vector2.new(.5, 1)
1749
	else
1750
		Viewport.Size = UDim2.new(0.3, 0, 0.3, 0)
1751
	end
1752
1753
	local RenderStepped = RunService.RenderStepped:Connect(function()
1754
		local Render = Camera.CFrame
1755
		local Scale = Camera.ViewportSize
1756
1757
		if VRReady then
1758
			Render = Render * VRService:GetUserCFrame(Enum.UserCFrame.Head)
1759
		end
1760
1761
		CameraPort = CFrame.new(Render.p + Vector3.new(5, 2, 0), Render.p)
1762
1763
		Viewport.Camera.CFrame = CameraPort
1764
1765
		ViewPart.CFrame = Render * CFrame.new(0, 0, -16)
1766
1767
		ViewHUD.Size = UDim2.new(0, Scale.X - 6, 0, Scale.Y - 6)
1768
	end)
1769
1770
	--
1771
1772
	local CharacterAdded
1773
1774
	CharacterAdded = Client.CharacterAdded:Connect(function()
1775
		if Viewport:FindFirstChild(Client.Name) then
1776
			Viewport[Client].Name:Destroy()
1777
			CharacterAdded(Client.Character)
1778
		end
1779
	end)
1780
1781
	wait(9e9)
1782
end;
1783
1784
Script()
1785
1786
wait(9e9)