View difference between Paste ID: TmEDDSNA and dyLby7jR
SHOW: | | - or go back to the newest paste.
1
-- CLOVR - FE FULL-BODY VR SCRIPT, UPDATED ON MARCH 17, 2020, TO SUPPORT ACTUAL CHARACTER USAGE
2
3
 
4
5
--  | made by 0866!!!!!!! and abacaxl!!!!!!!!
6
--  | tysm unverified
7
8
-- This is an older version of CLOVR, I found that the legs would 'walk' better in this version than the one we released. 
9
10
--Controls are a bit different from last release because this is older. Still works good!
11
12
--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
13
14
15
if game:GetService("RunService"):IsClient()then error("Please run as a server script. Use h/ instead of hl/.")end;print("FE Compatibility: by WaverlyCole");InternalData = {}
16
do
17
    script.Parent = owner.Character
18
    local Event = Instance.new("RemoteEvent");Event.Name = "UserInput"
19
    local function NewFakeEvent()
20
        local Bind = Instance.new("BindableEvent")
21
        local Fake;Fake = {Connections = {},
22
        fakeEvent=true;
23
        Connect=function(self,Func)
24
            Bind.Event:connect(Func)
25
            self.Connections[Bind] = true
26
            return setmetatable({Connected = true},{
27
            __index = function (self,Index)
28
                if Index:lower() == "disconnect" then
29
                    return function() Fake.Connections[Bind] = false;self.Connected = false end
30
                end
31
                return Fake[Index]
32
            end;
33
            __tostring = function() return "Connection" end;
34
        })
35
        end}
36
        Fake.connect = Fake.Connect;return Fake;
37
    end
38
    local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
39
    local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
40
    local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
41
        self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
42
    end};ContextActionService.UnBindAction = ContextActionService.BindAction
43
    local function TriggerEvent(self,Event,...)
44
        local Trigger = Mouse[Event]
45
        if Trigger and Trigger.fakeEvent and Trigger.Connections then
46
            for Connection,Active in pairs(Trigger.Connections) do if Active then Connection:Fire(...) end end
47
        end
48
    end
49
    Mouse.TrigEvent = TriggerEvent;UserInputService.TrigEvent = TriggerEvent
50
    Event.OnServerEvent:Connect(function(FiredBy,Input)
51
        if FiredBy.Name ~= owner.Name then return end
52
        if Input.MouseEvent then
53
            Mouse.Target = Input.Target;Mouse.Hit = Input.Hit
54
        else
55
            local Begin = Input.UserInputState == Enum.UserInputState.Begin
56
            if Input.UserInputType == Enum.UserInputType.MouseButton1 then return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up") end
57
            for _,Action in pairs(ContextActionService.Actions) do
58
                for _,Key in pairs(Action.Keys) do if Key==Input.KeyCode then Action.Function(Action.Name,Input.UserInputState,Input) end end
59
            end
60
            Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
61
            UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
62
        end
63
    end)
64
    InternalData["Mouse"] = Mouse;InternalData["ContextActionService"] = ContextActionService;InternalData["UserInputService"] = UserInputService
65
    Event.Parent = NLS([[
66
        local Player = owner;local Event = script:WaitForChild("UserInput");local UserInputService = game:GetService("UserInputService");local Mouse = Player:GetMouse()
67
        local Input = function(Input,gameProcessedEvent)
68
            if gameProcessedEvent then return end
69
            Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
70
        end
71
        UserInputService.InputBegan:Connect(Input);UserInputService.InputEnded:Connect(Input)
72
        local Hit,Target
73
        while wait(1/30) do
74
            if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
75
                Hit,Target = Mouse.Hit,Mouse.Target;Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
76
            end
77
        end
78
    ]],owner.Character)
79
end
80
RealGame = game;game = setmetatable({},{
81
    __index = function (self,Index)
82
        local Sandbox = function (Thing)
83
            if Thing:IsA("Player") then
84
                local RealPlayer = Thing
85
                return setmetatable({},{
86
                    __index = function (self,Index)
87
                        local Type = type(RealPlayer[Index])
88
                        if Type == "function" then
89
                            if Index:lower() == "getmouse" or Index:lower() == "mouse" then
90
                                return function (self)return InternalData["Mouse"] end
91
                            end
92
                            return function (self,...)return RealPlayer[Index](RealPlayer,...) end
93
                        end
94
                        return RealPlayer[Index]
95
                    end;
96
                    __tostring = function(self) return RealPlayer.Name end
97
                })
98
            end
99
        end
100
        if RealGame[Index] then
101
            local Type = type(RealGame[Index])
102
            if Type == "function" then
103
                if Index:lower() == "getservice" or Index:lower() == "service" then
104
                    return function (self,Service)
105
                        local FakeServices = {
106
                            ["players"] = function()
107
                                return setmetatable({},{
108
                                    __index = function (self2,Index2)
109
                                        local RealService = RealGame:GetService(Service)
110
                                        local Type2 = type(Index2)
111
                                        if Type2 == "function" then
112
                                            return function (self,...) return RealService[Index2](RealService,...)end
113
                                        else
114
                                            if Index2:lower() == "localplayer" then return Sandbox(owner) end
115
                                            return RealService[Index2]
116
                                        end
117
                                    end;
118
                                    __tostring = function(self) return RealGame:GetService(Service).Name end
119
                                })
120
                            end;
121
                            ["contextactionservice"] = function() return InternalData["ContextActionService"] end;
122
                            ["userinputservice"] = function() return InternalData["UserInputService"] end;
123
                            ["runservice"] = function()
124
                                return setmetatable({},{
125
                                    __index = function(self2,Index2)
126
                                        local RealService = RealGame:GetService(Service)
127
                                        local Type2 = type(Index2)
128
                                        if Type2 == "function" then
129
                                            return function (self,...) return RealService[Index2](RealService,...) end
130
                                        else
131
                                            local RunServices = {
132
                                                ["bindtorenderstep"] = function() return function (self,Name,Priority,Function) return RealGame:GetService("RunService").Stepped:Connect(Function) end end;
133
                                                ["renderstepped"] = function() return RealService["Stepped"] end
134
                                            }
135
                                            if RunServices[Index2:lower()] then return RunServices[Index2:lower()]() end
136
                                            return RealService[Index2]
137
                                        end
138
                                    end
139
                                })
140
                            end
141
                        }
142
                        if FakeServices[Service:lower()] then return FakeServices[Service:lower()]() end
143
                        return RealGame:GetService(Service)
144
                    end
145
                end
146
                return function (self,...) return RealGame[Index](RealGame,...) end
147
            else
148
                if game:GetService(Index) then return game:GetService(Index) end
149
                return RealGame[Index]
150
            end
151
        end
152
        return nil
153
    end
154
});Game = game;owner = game:GetService("Players").LocalPlayer;script = Instance.new("Script");print("Complete! Running...")
155
156
157
--|| Settings:
158
159
local StudsOffset = 0 -- Character height (negative if you're too high)
160
local Smoothness = .5 -- Character interpolation (0.1 - 1 = smooth - rigid)
161
162
local AnchorCharacter = true -- Prevent physics from causing inconsistencies
163
local HideCharacter = false -- Hide character on a platform
164
local NoCollision = true -- Disable player collision
165
166
local ChatEnabled = true -- See chat on your left hand in-game
167
 local ChatLocalRange = 75 -- Local chat range
168
169
local ViewportEnabled = true -- View nearby players in a frame
170
 local ViewportRange = 30 -- Maximum distance players are updated
171
172
local RagdollEnabled = true -- Use your character instead of hats (NetworkOwner vulnerability)
173
 local RagdollHeadMovement = true -- Move your head separately from your body (+9 second wait)
174
175
local AutoRun = false -- Run script on respawn
176
local AutoRespawn = true -- Kill your real body when your virtual body dies
177
178
local WearAllAccessories = true -- Use all leftover hats for the head
179
local AccurateHandPosition = true -- Move your Roblox hands according to your real hands
180
181
local AccessorySettings = {
182
	LeftArm		= "";
183
	RightArm	= "";
184
	LeftLeg		= "";
185
	RightLeg	= "";
186
	Torso		= "";
187
	Head		= true;
188
	
189
	BlockArms	= true;
190
	BlockLegs	= true;
191
	BlockTorso	= true;
192
	
193
	LimbOffset	= CFrame.Angles(math.rad(90), 0, 0);
194
}
195
196
local FootPlacementSettings = {
197
	RightOffset = Vector3.new(.5, 0, 0),
198
	LeftOffset = Vector3.new(-.5, 0, 0),
199
}
200
201
--|| Script:
202
203
local Script = nil;
204
205
Script = function()
206
207
--[[
208
	Variables
209
--]]
210
211
local Players = game:GetService("Players")
212
 local Client = Players.LocalPlayer
213
  local Character = Client.Character or Client.CharacterAdded:Wait()
214
   local WeldBase = Character:WaitForChild("HumanoidRootPart")
215
   local ArmBase = Character:FindFirstChild("RightHand") or Character:FindFirstChild("Right Arm") or WeldBase
216
  local Backpack = Client:WaitForChild("Backpack")
217
  local Mouse = Client:GetMouse()
218
219
local Camera = workspace.CurrentCamera
220
221
local VRService = game:GetService("VRService")
222
 local VRReady = VRService.VREnabled
223
224
local UserInputService = game:GetService("UserInputService")
225
local RunService = game:GetService("RunService")
226
local HttpService = game:GetService("HttpService")
227
local StarterGui = game:GetService("StarterGui")	
228
229
local HeadAccessories = {};
230
local UsedAccessories = {};
231
232
local Pointer = false;
233
local Point1 = false;
234
local Point2 = false;
235
236
local VirtualRig = game:GetObjects("rbxassetid://4468539481")[1]
237
local VirtualBody = game:GetObjects("rbxassetid://4464983829")[1]
238
239
local Anchor = Instance.new("Part")
240
241
Anchor.Anchored = true
242
Anchor.Transparency = 1
243
Anchor.CanCollide = false
244
Anchor.Parent = workspace
245
246
if RagdollEnabled then
247
	print("RagdollEnabled, thank you for using CLOVR!")
248
	local NetworkAccess = coroutine.create(function()
249
settings().Physics.AllowSleep = false
250
while true do game:GetService("RunService").RenderStepped:Wait()
251
for _,Players in next, game:GetService("Players"):GetChildren() do
252
if Players ~= game:GetService("Players").LocalPlayer then
253
Players.MaximumSimulationRadius = 0.1 Players.SimulationRadius = 0 end end
254
game:GetService("Players").LocalPlayer.MaximumSimulationRadius = math.pow(math.huge,math.huge)
255
game:GetService("Players").LocalPlayer.SimulationRadius = math.huge*math.huge end end)
256
coroutine.resume(NetworkAccess)
257
end
258
259
StarterGui:SetCore("VRLaserPointerMode", 3)
260
261
--[[
262
	Character Protection
263
--]]
264
265
local CharacterCFrame = WeldBase.CFrame
266
267
if not RagdollEnabled then
268
	Character.Humanoid.AnimationPlayed:Connect(function(Animation)
269
		Animation:Stop()
270
	end)
271
	
272
	for _, Track in next, Character.Humanoid:GetPlayingAnimationTracks() do
273
		Track:Stop()
274
	end
275
	
276
	if HideCharacter then
277
		local Platform = Instance.new("Part")
278
		
279
		Platform.Anchored = true
280
		Platform.Size = Vector3.new(100, 5, 100)
281
		Platform.CFrame = CFrame.new(0, 10000, 0)
282
		Platform.Transparency = 1
283
		Platform.Parent = workspace
284
		
285
		Character:MoveTo(Platform.Position + Vector3.new(0, 5, 0))
286
		
287
		wait(.5)
288
	end
289
	
290
	if AnchorCharacter then
291
		for _, Part in pairs(Character:GetChildren()) do
292
			if Part:IsA("BasePart") then
293
				Part.Anchored = true
294
			end
295
		end
296
	end
297
end
298
299
--[[
300
	Functions
301
--]]
302
303
function Tween(Object, Style, Direction, Time, Goal)
304
    local tweenInfo = TweenInfo.new(Time, Enum.EasingStyle[Style], Enum.EasingDirection[Direction])
305
    local tween = game:GetService("TweenService"):Create(Object, tweenInfo, Goal)
306
307
	tween.Completed:Connect(function()
308
		tween:Destroy()
309
	end)
310
	
311
    tween:Play()
312
313
    return tween
314
end
315
316
local function GetMotorForLimb(Limb)
317
	for _, Motor in next, Character:GetDescendants() do
318
		if Motor:IsA("Motor6D") and Motor.Part1 == Limb then
319
			return Motor
320
		end
321
	end
322
end
323
324
local function CreateAlignment(Limb, Part0)
325
	local Attachment0 = Instance.new("Attachment", Part0 or Anchor)
326
	local Attachment1 = Instance.new("Attachment", Limb)
327
	
328
	local Orientation = Instance.new("AlignOrientation")
329
	local Position = Instance.new("AlignPosition")
330
	
331
	Orientation.Attachment0 = Attachment1
332
	Orientation.Attachment1 = Attachment0
333
	Orientation.RigidityEnabled = false
334
	Orientation.MaxTorque = 20000
335
	Orientation.Responsiveness = 40
336
	Orientation.Parent = Character.HumanoidRootPart
337
	
338
	Position.Attachment0 = Attachment1
339
	Position.Attachment1 = Attachment0
340
	Position.RigidityEnabled = false
341
	Position.MaxForce = 40000
342
	Position.Responsiveness = 40
343
	Position.Parent = Character.HumanoidRootPart
344
	
345
	Limb.Massless = false
346
	
347
	local Motor = GetMotorForLimb(Limb)
348
	if Motor then
349
		Motor:Destroy()
350
	end
351
	
352
	return function(CF, Local)
353
		if Local then
354
			Attachment0.CFrame = CF
355
		else
356
			Attachment0.WorldCFrame = CF
357
		end
358
	end;
359
end
360
361
local function GetExtraTool()
362
	for _, Tool in next, Character:GetChildren() do
363
		if Tool:IsA("Tool") and not Tool.Name:match("LIMB_TOOL") then
364
			return Tool
365
		end
366
	end
367
end
368
369
local function GetGripForHandle(Handle)
370
	for _, Weld in next, Character:GetDescendants() do
371
		if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
372
			return Weld
373
		end
374
	end
375
	
376
	wait(.2)
377
	
378
	for _, Weld in next, Character:GetDescendants() do
379
		if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
380
			return Weld
381
		end
382
	end
383
end
384
385
local function CreateRightGrip(Handle)
386
	local RightGrip = Instance.new("Weld")
387
	
388
	RightGrip.Name = "RightGrip"
389
	RightGrip.Part1 = Handle
390
	RightGrip.Part0 = WeldBase
391
	RightGrip.Parent = WeldBase
392
	
393
	return RightGrip
394
end
395
396
local function CreateAccessory(Accessory, DeleteMeshes)
397
	if not Accessory then
398
		return
399
	end
400
	
401
	local HatAttachment = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
402
	local HeadAttachment = VirtualRig:FindFirstChild(HatAttachment.Name, true)
403
	local BasePart = HeadAttachment.Parent
404
	
405
	local HatAtt = HatAttachment.CFrame
406
	local HeadAtt = HeadAttachment.CFrame
407
	
408
	if DeleteMeshes then
409
		if Accessory.Handle:FindFirstChild("Mesh") then
410
			Accessory.Handle.Mesh:Destroy()
411
		end
412
	end
413
	
414
	wait()
415
	
416
	local Handle = Accessory:WaitForChild("Handle")
417
	
418
	if Handle:FindFirstChildWhichIsA("Weld", true) then
419
		Handle:FindFirstChildWhichIsA("Weld", true):Destroy()
420
		Handle:BreakJoints()
421
	else
422
		Handle:BreakJoints()
423
	end
424
	
425
	Handle.Massless = true
426
	Handle.Transparency = 0.5
427
	
428
	UsedAccessories[Accessory] = true
429
	
430
	local RightGrip = CreateRightGrip(Handle)
431
	
432
	wait()
433
	
434
	for _, Object in pairs(Handle:GetDescendants()) do
435
		if not Object:IsA("BasePart") then
436
			pcall(function()
437
				Object.Transparency = 1
438
			end)
439
			
440
			pcall(function()
441
				Object.Enabled = false
442
			end)
443
		end
444
	end
445
	
446
	return Handle, RightGrip, HatAtt, HeadAtt, BasePart;
447
end
448
449
local function GetHeadAccessories()
450
	for _, Accessory in next, Character:GetChildren() do
451
		if Accessory:IsA("Accessory") and not UsedAccessories[Accessory] then
452
			local Handle, RightGrip, HatAtt, HeadAtt, BasePart = CreateAccessory(Accessory)
453
			
454
			table.insert(HeadAccessories, {Handle, RightGrip, HatAtt, HeadAtt, BasePart})
455
			
456
			do
457
				Handle.Transparency = 1
458
			end
459
			
460
			if not WearAllAccessories then
461
				break
462
			end
463
		end
464
	end
465
end
466
467
--[[
468
	VR Replication Setup
469
--]]
470
471
if not RagdollEnabled then
472
	LeftHandle, LeftHandGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftArm), AccessorySettings.BlockArms)
473
	RightHandle, RightHandGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.RightArm), AccessorySettings.BlockArms)
474
	LeftHipHandle, LeftLegGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftLeg), AccessorySettings.BlockLegs)
475
	RightHipHandle, RightLegGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.RightLeg), AccessorySettings.BlockLegs)
476
	TorsoHandle, TorsoGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.Torso), AccessorySettings.BlockTorso)
477
	GetHeadAccessories()
478
	
479
elseif RagdollEnabled then
480
	if RagdollHeadMovement then
481
		Permadeath()
482
		MoveHead = CreateAlignment(Character["Head"])
483
	end
484
	
485
	MoveRightArm = CreateAlignment(Character["Right Arm"])
486
	MoveLeftArm = CreateAlignment(Character["Left Arm"])
487
	MoveRightLeg = CreateAlignment(Character["Right Leg"])
488
	MoveLeftLeg = CreateAlignment(Character["Left Leg"])
489
	MoveTorso = CreateAlignment(Character["Torso"])
490
	MoveRoot = CreateAlignment(Character.HumanoidRootPart)
491
	
492
	if RagdollHeadMovement then
493
		for _, Accessory in next, Character:GetChildren() do
494
			if Accessory:IsA("Accessory") and Accessory:FindFirstChild("Handle") then
495
				local Attachment1 = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
496
				local Attachment0 = Character:FindFirstChild(tostring(Attachment1), true)
497
				
498
				local Orientation = Instance.new("AlignOrientation")
499
				local Position = Instance.new("AlignPosition")
500
				
501
				print(Attachment1, Attachment0, Accessory)
502
				
503
				Orientation.Attachment0 = Attachment1
504
				Orientation.Attachment1 = Attachment0
505
				Orientation.RigidityEnabled = false
506
				Orientation.ReactionTorqueEnabled = true
507
				Orientation.MaxTorque = 20000
508
				Orientation.Responsiveness = 40
509
				Orientation.Parent = Character.Head
510
				
511
				Position.Attachment0 = Attachment1
512
				Position.Attachment1 = Attachment0
513
				Position.RigidityEnabled = false
514
				Position.ReactionForceEnabled = true
515
				Position.MaxForce = 40000
516
				Position.Responsiveness = 40
517
				Position.Parent = Character.Head
518
			end
519
		end
520
	end
521
end
522
523
--[[
524
	Movement
525
--]]
526
527
VirtualRig.Name = "VirtualRig"
528
VirtualRig.RightFoot.BodyPosition.Position = CharacterCFrame.p
529
VirtualRig.LeftFoot.BodyPosition.Position = CharacterCFrame.p
530
VirtualRig.Parent = workspace
531
VirtualRig:SetPrimaryPartCFrame(CharacterCFrame)
532
533
VirtualRig.Humanoid.Health = 0
534
VirtualRig:BreakJoints()
535
--
536
537
VirtualBody.Parent = workspace
538
VirtualBody.Name = "VirtualBody"
539
VirtualBody.Humanoid.WalkSpeed = 8
540
VirtualBody.Humanoid.CameraOffset = Vector3.new(0, StudsOffset, 0)
541
VirtualBody:SetPrimaryPartCFrame(CharacterCFrame)
542
543
VirtualBody.Humanoid.Died:Connect(function()
544
	print("Virtual death")
545
	if AutoRespawn then
546
		Character:BreakJoints()
547
		
548
		if RagdollHeadMovement and RagdollEnabled then
549
			Network:Unclaim()
550
			Respawn()
551
		end
552
	end
553
end)
554
--
555
556
Camera.CameraSubject = VirtualBody.Humanoid
557
558
Character.Humanoid.WalkSpeed = 0
559
Character.Humanoid.JumpPower = 1
560
561
for _, Part in next, VirtualBody:GetChildren() do
562
	if Part:IsA("BasePart") then
563
		Part.Transparency = 1
564
	end
565
end
566
567
for _, Part in next, VirtualRig:GetChildren() do
568
	if Part:IsA("BasePart") then
569
		Part.Transparency = 1
570
	end
571
end
572
573
if not VRReady then
574
	VirtualRig.RightUpperArm.ShoulderConstraint.RigidityEnabled = true
575
	VirtualRig.LeftUpperArm.ShoulderConstraint.RigidityEnabled = true
576
end
577
578
579
local OnMoving = RunService.Stepped:Connect(function()
580
	local Direction = Character.Humanoid.MoveDirection
581
	local Start = VirtualBody.HumanoidRootPart.Position
582
	local Point = Start + Direction * 6
583
	
584
	VirtualBody.Humanoid:MoveTo(Point)
585
end)
586
587
Character.Humanoid.Jumping:Connect(function()
588
	VirtualBody.Humanoid.Jump = true
589
end)
590
591
UserInputService.JumpRequest:Connect(function()
592
	VirtualBody.Humanoid.Jump = true
593
end)
594
595
--[[
596
	VR Replication
597
--]]
598
599
if RagdollEnabled then
600
	for _, Part in pairs(Character:GetDescendants()) do
601
		if Part:IsA("BasePart") and Part.Name == "Handle" and Part.Parent:IsA("Accessory") then
602
			Part.LocalTransparencyModifier = 1
603
		elseif Part:IsA("BasePart") and Part.Transparency < 0.5 and Part.Name ~= "Head" then
604
			Part.LocalTransparencyModifier = 0.5
605
		elseif Part:IsA("BasePart") and Part.Name == "Head" then
606
			Part.LocalTransparencyModifier = 1
607
		end
608
		
609
		if not Part:IsA("BasePart") and not Part:IsA("AlignPosition") and not Part:IsA("AlignOrientation") then
610
			pcall(function()
611
				Part.Transparency = 1
612
			end)
613
			
614
			pcall(function()
615
				Part.Enabled = false
616
			end)
617
		end
618
	end
619
end
620
621
local FootUpdateDebounce = tick()
622
623
local function FloorRay(Part, Distance)
624
	local Position = Part.CFrame.p
625
	local Target = Position - Vector3.new(0, Distance, 0)
626
	local Line = Ray.new(Position, (Target - Position).Unit * Distance)
627
	
628
	local FloorPart, FloorPosition, FloorNormal = workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character})
629
	
630
	if FloorPart then
631
		return FloorPart, FloorPosition, FloorNormal, (FloorPosition - Position).Magnitude
632
	else
633
		return nil, Target, Vector3.new(), Distance
634
	end
635
end
636
637
local function Flatten(CF)
638
	local X,Y,Z = CF.X,CF.Y,CF.Z
639
	local LX,LZ = CF.lookVector.X,CF.lookVector.Z
640
	
641
	return CFrame.new(X,Y,Z) * CFrame.Angles(0,math.atan2(LX,LZ),0)
642
end
643
644
local FootTurn = 1
645
646
local function FootReady(Foot, Target)
647
	local MaxDist
648
	
649
	if Character.Humanoid.MoveDirection.Magnitude > 0 then
650
		MaxDist = .5
651
	else
652
		MaxDist = 1
653
	end
654
	
655
	local PastThreshold = (Foot.Position - Target.Position).Magnitude > MaxDist
656
	local PastTick = tick() - FootUpdateDebounce >= 2
657
	
658
	if PastThreshold or PastTick then
659
		FootUpdateDebounce = tick()
660
	end
661
	
662
	return
663
		PastThreshold
664
	or
665
		PastTick
666
end
667
668
local function FootYield()
669
	local RightFooting = VirtualRig.RightFoot.BodyPosition
670
	local LeftFooting = VirtualRig.LeftFoot.BodyPosition
671
	local LowerTorso = VirtualRig.LowerTorso
672
	
673
	local Yield = tick()
674
	
675
	repeat
676
		RunService.Stepped:Wait()
677
		if
678
			(LowerTorso.Position - RightFooting.Position).Y > 4
679
		or
680
			(LowerTorso.Position - LeftFooting.Position).Y > 4
681
		or
682
			((LowerTorso.Position - RightFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4
683
		or
684
			((LowerTorso.Position - LeftFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4
685
		then
686
			break
687
		end
688
	until tick() - Yield >= .17
689
end
690
691
local function UpdateFooting()
692
	if not VirtualRig:FindFirstChild("LowerTorso") then
693
		wait()
694
		return
695
	end
696
	
697
	local Floor, FloorPosition, FloorNormal, Dist = FloorRay(VirtualRig.LowerTorso, 3)
698
	
699
	Dist = math.clamp(Dist, 0, 5)
700
	
701
	local FootTarget = 
702
		VirtualRig.LowerTorso.CFrame *
703
		CFrame.new(FootPlacementSettings.RightOffset) -
704
		Vector3.new(0, Dist, 0) +
705
		Character.Humanoid.MoveDirection * (VirtualBody.Humanoid.WalkSpeed / 8) * 2
706
	
707
	if FootReady(VirtualRig.RightFoot, FootTarget) then
708
		VirtualRig.RightFoot.BodyPosition.Position = FootTarget.p
709
		VirtualRig.RightFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
710
	end
711
	
712
	FootYield()
713
	
714
	local FootTarget = 
715
		VirtualRig.LowerTorso.CFrame *
716
		CFrame.new(FootPlacementSettings.LeftOffset) -
717
		Vector3.new(0, Dist, 0) +
718
		Character.Humanoid.MoveDirection * (VirtualBody.Humanoid.WalkSpeed / 8) * 2
719
	
720
	if FootReady(VirtualRig.LeftFoot, FootTarget) then
721
		VirtualRig.LeftFoot.BodyPosition.Position = FootTarget.p
722
		VirtualRig.LeftFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
723
	end
724
end
725
726
local function UpdateTorsoPosition()
727
	if not RagdollEnabled then
728
		if TorsoHandle then
729
			local Positioning = VirtualRig.UpperTorso.CFrame
730
			
731
			if not TorsoGrip or not TorsoGrip.Parent then
732
				TorsoGrip = CreateRightGrip(TorsoHandle)
733
			end
734
			
735
			local Parent = TorsoGrip.Parent
736
			
737
			TorsoGrip.C1 = CFrame.new()
738
			TorsoGrip.C0 = TorsoGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(Positioning * CFrame.new(0, -0.25, 0) * AccessorySettings.LimbOffset), Smoothness)
739
			TorsoGrip.Parent = nil
740
			TorsoGrip.Parent = Parent
741
		end
742
	else
743
		local Positioning = VirtualRig.UpperTorso.CFrame
744
		
745
		MoveTorso(Positioning * CFrame.new(0, -0.25, 0))
746
		MoveRoot(Positioning * CFrame.new(0, -0.25, 0))
747
	end
748
end
749
750
local function UpdateLegPosition()
751
	if not RagdollEnabled then
752
		if RightHipHandle then
753
			local Positioning =
754
				VirtualRig.RightLowerLeg.CFrame
755
				: Lerp(VirtualRig.RightFoot.CFrame, 0.5)
756
				+ Vector3.new(0, 0.5, 0)
757
			
758
			if not RightHipHandle or not RightHipHandle.Parent then
759
				RightLegGrip = CreateRightGrip(RightHipHandle)
760
			end
761
			
762
			local Parent = RightLegGrip.Parent
763
			
764
			RightLegGrip.C1 = CFrame.new()
765
			RightLegGrip.C0 = RightLegGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(Positioning * AccessorySettings.LimbOffset), Smoothness)
766
			RightLegGrip.Parent = nil
767
			RightLegGrip.Parent = Parent
768
		end
769
		
770
		if LeftHipHandle then
771
			local Positioning =
772
				VirtualRig.LeftLowerLeg.CFrame
773
				: Lerp(VirtualRig.LeftFoot.CFrame, 0.5)
774
				+ Vector3.new(0, 0.5, 0)
775
			
776
			if not LeftLegGrip or not LeftLegGrip.Parent then
777
				LeftLegGrip = CreateRightGrip(LeftHipHandle)
778
			end
779
			
780
			local Parent = LeftLegGrip.Parent
781
			
782
			LeftLegGrip.C1 = CFrame.new()
783
			LeftLegGrip.C0 = LeftLegGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(Positioning * AccessorySettings.LimbOffset), Smoothness)
784
			LeftLegGrip.Parent = nil
785
			LeftLegGrip.Parent = Parent
786
		end
787
	else
788
		do
789
			local Positioning =
790
				VirtualRig.RightLowerLeg.CFrame
791
				: Lerp(VirtualRig.RightFoot.CFrame, 0.5)
792
				* CFrame.Angles(0, math.rad(180), 0)
793
				+ Vector3.new(0, 0.5, 0)
794
			
795
			MoveRightLeg(Positioning)
796
		end
797
		
798
		do
799
			local Positioning =
800
				VirtualRig.LeftLowerLeg.CFrame
801
				: Lerp(VirtualRig.LeftFoot.CFrame, 0.5)
802
				* CFrame.Angles(0, math.rad(180), 0)
803
				+ Vector3.new(0, 0.5, 0)
804
			
805
			MoveLeftLeg(Positioning)
806
		end
807
	end
808
end
809
810
warn("VRReady is", VRReady)
811
812
local function OnUserCFrameChanged(UserCFrame, Positioning, IgnoreTorso)
813
	local Positioning = Camera.CFrame * Positioning
814
	
815
	if not IgnoreTorso then
816
		UpdateTorsoPosition()
817
		UpdateLegPosition()
818
	end
819
	
820
	if not RagdollEnabled then
821
		if UserCFrame == Enum.UserCFrame.Head and AccessorySettings.Head then
822
			for _, Table in next, HeadAccessories do
823
				local Handle, RightGrip, HatAtt, HeadAtt, BasePart = unpack(Table)
824
				local LocalPositioning = Positioning
825
				
826
				if not RightGrip or not RightGrip.Parent then
827
					RightGrip = CreateRightGrip(Handle)
828
					Table[2] = RightGrip
829
				end
830
				
831
				local Parent = RightGrip.Parent
832
				
833
				if BasePart then
834
					LocalPositioning = BasePart.CFrame * HeadAtt
835
				end
836
				
837
				RightGrip.C1 = HatAtt
838
				RightGrip.C0 = RightGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(LocalPositioning), Smoothness)
839
				RightGrip.Parent = nil
840
				RightGrip.Parent = Parent
841
			end
842
			
843
		elseif RightHandle and UserCFrame == Enum.UserCFrame.RightHand and AccessorySettings.RightArm then
844
			local HandPosition = Positioning
845
			local LocalPositioning = Positioning
846
			
847
			if not RightHandGrip or not RightHandGrip.Parent then
848
				RightHandGrip = CreateRightGrip(RightHandle)
849
			end
850
			
851
			if AccurateHandPosition then
852
				HandPosition = HandPosition * CFrame.new(0, 0, 1)
853
			end
854
			
855
			if not VRReady then
856
				local HeadRotation = Camera.CFrame - Camera.CFrame.p
857
				
858
				HandPosition = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5) * AccessorySettings.LimbOffset
859
				
860
				--LocalPositioning = (HeadRotation + (HandPosition * CFrame.new(0, 0, 1)).p) * CFrame.Angles(math.rad(-45), 0, 0)
861
				LocalPositioning = HandPosition * CFrame.new(0, 0, 1) * CFrame.Angles(math.rad(-180), 0, 0)
862
				
863
				if Point2 then
864
					VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
865
					VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
866
				elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
867
					VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
868
				end
869
			elseif AccurateHandPosition then
870
				LocalPositioning = HandPosition
871
			end
872
			
873
			local Parent = RightHandGrip.Parent
874
			
875
			RightHandGrip.C1 = CFrame.new()
876
			RightHandGrip.C0 = RightHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
877
			RightHandGrip.Parent = nil
878
			RightHandGrip.Parent = Parent
879
			
880
			--
881
			
882
			local EquippedTool = GetExtraTool()
883
			
884
			if EquippedTool and EquippedTool:FindFirstChild("Handle") then
885
				local EquippedGrip = GetGripForHandle(EquippedTool.Handle)
886
				local Parent = EquippedGrip.Parent
887
				
888
				local ArmBaseCFrame = ArmBase.CFrame
889
				if ArmBase.Name == "Right Arm" then
890
					ArmBaseCFrame = ArmBaseCFrame
891
				end
892
				
893
				EquippedGrip.C1 = EquippedTool.Grip
894
				EquippedGrip.C0 = EquippedGrip.C0:Lerp(ArmBaseCFrame:ToObjectSpace(LocalPositioning), Smoothness)
895
				EquippedGrip.Parent = nil
896
				EquippedGrip.Parent = Parent
897
			end
898
			
899
		elseif LeftHandle and UserCFrame == Enum.UserCFrame.LeftHand and AccessorySettings.LeftArm then
900
			local HandPosition = Positioning
901
			
902
			if not LeftHandGrip or not LeftHandGrip.Parent then
903
				LeftHandGrip = CreateRightGrip(LeftHandle)
904
			end
905
			
906
			if AccurateHandPosition then
907
				HandPosition = HandPosition * CFrame.new(0, 0, 1)
908
			end
909
			
910
			if not VRReady then
911
				HandPosition = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5) * AccessorySettings.LimbOffset
912
				--warn("Setting HandPosition to hands")
913
				if Point1 then
914
					VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
915
					VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
916
				elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
917
					VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
918
				end
919
			end
920
			
921
			local Parent = LeftHandGrip.Parent
922
			
923
			LeftHandGrip.C1 = CFrame.new()
924
			LeftHandGrip.C0 = LeftHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
925
			LeftHandGrip.Parent = nil
926
			LeftHandGrip.Parent = Parent
927
			
928
		end
929
	end
930
	
931
	if RagdollEnabled then
932
		if UserCFrame == Enum.UserCFrame.Head and RagdollHeadMovement then
933
			MoveHead(Positioning)
934
		elseif UserCFrame == Enum.UserCFrame.RightHand then
935
			local Positioning = Positioning
936
			
937
			if not VRReady then
938
				Positioning = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5)
939
			elseif AccurateHandPosition then
940
				Positioning = Positioning * CFrame.new(0, 0, 1)
941
			end
942
			
943
			if VRReady then
944
				Positioning = Positioning * AccessorySettings.LimbOffset
945
			end
946
			
947
			MoveRightArm(Positioning)
948
			
949
			if Point2 then
950
				VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
951
				VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
952
			elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
953
				VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
954
			end
955
		elseif UserCFrame == Enum.UserCFrame.LeftHand then
956
			local Positioning = Positioning
957
			
958
			if not VRReady then
959
				Positioning = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5)
960
			elseif AccurateHandPosition then
961
				Positioning = Positioning * CFrame.new(0, 0, 1)
962
			end
963
			
964
			if VRReady then
965
				Positioning = Positioning * AccessorySettings.LimbOffset
966
			end
967
			
968
			MoveLeftArm(Positioning)
969
			
970
			if Point1 then
971
				VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
972
				VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
973
			elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
974
				VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
975
			end
976
		end
977
	end
978
	
979
	if UserCFrame == Enum.UserCFrame.Head then
980
		VirtualRig.Head.CFrame = Positioning
981
		
982
	elseif UserCFrame == Enum.UserCFrame.RightHand and VRReady then
983
		VirtualRig.RightHand.CFrame = Positioning
984
		
985
	elseif UserCFrame == Enum.UserCFrame.LeftHand and VRReady then
986
		VirtualRig.LeftHand.CFrame = Positioning
987
		
988
	end
989
	
990
	if not VRReady and VirtualRig.LeftHand.Anchored then
991
		VirtualRig.RightHand.Anchored = false
992
		VirtualRig.LeftHand.Anchored = false
993
	elseif VRReady and not VirtualRig.LeftHand.Anchored then
994
		VirtualRig.RightHand.Anchored = true
995
		VirtualRig.LeftHand.Anchored = true
996
	end
997
end
998
999
local CFrameChanged = VRService.UserCFrameChanged:Connect(OnUserCFrameChanged)
1000
1001
local OnStepped = RunService.Stepped:Connect(function()
1002
	for _, Part in pairs(VirtualRig:GetChildren()) do
1003
		if Part:IsA("BasePart") then
1004
			Part.CanCollide = false
1005
		end
1006
	end
1007
	
1008
	if RagdollEnabled then
1009
		for _, Part in pairs(Character:GetChildren()) do
1010
			if Part:IsA("BasePart") then
1011
				Part.CanCollide = false
1012
			end
1013
		end
1014
	end
1015
	
1016
	if NoCollision then
1017
		for _, Player in pairs(Players:GetPlayers()) do
1018
			if Player ~= Client and Player.Character then
1019
				local Descendants = Player.Character:GetDescendants()
1020
				for i = 1, #Descendants do
1021
					local Part = Descendants[i]
1022
					if Part:IsA("BasePart") then
1023
						Part.CanCollide = false
1024
						Part.Velocity = Vector3.new()
1025
						Part.RotVelocity = Vector3.new()
1026
					end
1027
				end
1028
			end
1029
		end
1030
	end
1031
end)
1032
1033
local OnRenderStepped = RunService.Stepped:Connect(function()
1034
	Camera.CameraSubject = VirtualBody.Humanoid
1035
	
1036
	if RagdollEnabled then
1037
		Character.HumanoidRootPart.CFrame = VirtualRig.UpperTorso.CFrame
1038
		Character.HumanoidRootPart.Velocity = Vector3.new(0, 0, 0)
1039
	end
1040
	
1041
	if not VRReady then
1042
		OnUserCFrameChanged(Enum.UserCFrame.Head, CFrame.new(0, 0, 0))
1043
		
1044
		OnUserCFrameChanged(Enum.UserCFrame.RightHand, CFrame.new(0, 0, 0), true)
1045
		OnUserCFrameChanged(Enum.UserCFrame.LeftHand, CFrame.new(0, 0, 0), true)
1046
	end
1047
end)
1048
1049
spawn(function()
1050
	while Character and Character.Parent do
1051
		FootYield()
1052
		UpdateFooting()
1053
	end
1054
end)
1055
1056
--[[
1057
	Non-VR Support + VR Mechanics
1058
--]]
1059
1060
local OnInput = UserInputService.InputBegan:Connect(function(Input, Processed)
1061
	if not Processed then
1062
		if Input.KeyCode == Enum.KeyCode.LeftControl or Input.KeyCode == Enum.KeyCode.ButtonL2 then
1063
			Tween(VirtualBody.Humanoid, "Elastic", "Out", 1, {
1064
				CameraOffset = Vector3.new(0, StudsOffset - 1.5, 0)
1065
			})
1066
		end
1067
	
1068
		if Input.KeyCode == Enum.KeyCode.X then
1069
			if RagdollEnabled and RagdollHeadMovement then
1070
				Network:Unclaim()
1071
				Respawn()
1072
			end
1073
		end
1074
		
1075
		if Input.KeyCode == Enum.KeyCode.C then
1076
			VirtualBody:MoveTo(Mouse.Hit.p)
1077
			VirtualRig:MoveTo(Mouse.Hit.p)
1078
		end
1079
	end
1080
		
1081
	if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.ButtonR2 then
1082
		Tween(VirtualBody.Humanoid, "Sine", "Out", 1, {
1083
			WalkSpeed = 16
1084
		})
1085
	end
1086
	
1087
	if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton1 then
1088
		Point1 = true
1089
	end
1090
	
1091
	if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton2 then
1092
		Point2 = true
1093
	end
1094
	
1095
	if VRReady and Input.KeyCode == Enum.KeyCode.ButtonY then
1096
		Character:BreakJoints()
1097
		
1098
		if RagdollEnabled and RagdollHeadMovement then
1099
			Network:Unclaim()
1100
			Respawn()
1101
		end
1102
	end
1103
end)
1104
1105
local OnInputEnded = UserInputService.InputEnded:Connect(function(Input, Processed)
1106
	if not Processed then
1107
		if Input.KeyCode == Enum.KeyCode.LeftControl or Input.KeyCode == Enum.KeyCode.ButtonL2 then
1108
			Tween(VirtualBody.Humanoid, "Elastic", "Out", 1, {
1109
				CameraOffset = Vector3.new(0, StudsOffset, 0)
1110
			})
1111
		end
1112
	end
1113
		
1114
	if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.ButtonR2 then
1115
		Tween(VirtualBody.Humanoid, "Sine", "Out", 1, {
1116
			WalkSpeed = 8
1117
		})
1118
	end
1119
	
1120
	if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton1 then
1121
		Point1 = false
1122
	end
1123
	
1124
	if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton2 then
1125
		Point2 = false
1126
	end
1127
end)
1128
1129
--[[
1130
	Proper Cleanup
1131
--]]
1132
1133
local OnReset
1134
1135
OnReset = Client.CharacterAdded:Connect(function()
1136
	OnReset:Disconnect();
1137
	CFrameChanged:Disconnect();
1138
	OnStepped:Disconnect();
1139
	OnRenderStepped:Disconnect();
1140
	OnMoving:Disconnect();
1141
	OnInput:Disconnect();
1142
	OnInputEnded:Disconnect();
1143
	
1144
	VirtualRig:Destroy();
1145
	VirtualBody:Destroy();
1146
	
1147
	if RagdollEnabled then
1148
		Network:Unclaim();
1149
	end
1150
	
1151
	if AutoRun then
1152
		delay(2, function()
1153
			Script()
1154
		end)
1155
	end
1156
end)
1157
1158
if ChatEnabled then
1159
	spawn(ChatHUDFunc)
1160
end
1161
1162
if ViewportEnabled then
1163
	spawn(ViewHUDFunc)
1164
end
1165
1166
do
1167
	--[[
1168
		Functions
1169
	--]]
1170
	
1171
	local Players = game:GetService("Players")
1172
	 local Client = Players.LocalPlayer
1173
	
1174
	local VRService = game:GetService("VRService")
1175
	 local VRReady = VRService.VREnabled
1176
	
1177
	local UserInputService = game:GetService("UserInputService")
1178
	local RunService = game:GetService("RunService")
1179
	
1180
	local Camera = workspace.CurrentCamera
1181
	
1182
	--[[
1183
		Code
1184
	--]]
1185
	
1186
	if VRReady then
1187
		local Pointer = game:GetObjects("rbxassetid://4476173280")[1]
1188
		
1189
		Pointer.Parent = workspace
1190
		Pointer.Beam.Enabled = false
1191
		Pointer.Target.ParticleEmitter.Enabled = false
1192
		
1193
		local RenderStepped = RunService.RenderStepped:Connect(function()
1194
			if Pointer.Beam.Enabled then
1195
				local RightHand = Camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
1196
				local Target = RightHand * CFrame.new(0, 0, -10)
1197
				
1198
				local Line = Ray.new(RightHand.p, (Target.p - RightHand.p).Unit * 128)
1199
				local Part, Position = workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character, Pointer})
1200
				
1201
				local Distance = (Position - RightHand.p).Magnitude
1202
				
1203
				Pointer.Target.Position = Vector3.new(0, 0, -Distance)
1204
				Pointer.CFrame = RightHand
1205
			end
1206
		end)
1207
		
1208
		local Input = UserInputService.InputBegan:Connect(function(Input)
1209
			if Input.KeyCode == Enum.KeyCode.ButtonB then
1210
				Pointer.Beam.Enabled = not Pointer.Beam.Enabled
1211
				Pointer.Target.ParticleEmitter.Enabled = not Pointer.Target.ParticleEmitter.Enabled
1212
			end
1213
		end)
1214
		
1215
		--
1216
		
1217
		local CharacterAdded
1218
		
1219
		CharacterAdded = Client.CharacterAdded:Connect(function()
1220
			RenderStepped:Disconnect()
1221
			Input:Disconnect()
1222
			CharacterAdded:Disconnect()
1223
			
1224
			Pointer:Destroy()
1225
			Pointer = nil
1226
		end)
1227
	else
1228
		return
1229
	end
1230
end
1231
1232
end;
1233
1234
Permadeath = function()
1235
	local ch = game.Players.LocalPlayer.Character
1236
	local prt=Instance.new("Model", workspace)
1237
	local z1 =  Instance.new("Part", prt)
1238
	z1.Name="Torso"
1239
	z1.CanCollide = false
1240
	z1.Anchored = true
1241
	local z2  =Instance.new("Part", prt)
1242
	z2.Name="Head"
1243
	z2.Anchored = true
1244
	z2.CanCollide = false
1245
	local z3 =Instance.new("Humanoid", prt)
1246
	z3.Name="Humanoid"
1247
	z1.Position = Vector3.new(0,9999,0)
1248
	z2.Position = Vector3.new(0,9991,0)
1249
	game.Players.LocalPlayer.Character=prt
1250
	wait(5)
1251
	warn("50%")
1252
	game.Players.LocalPlayer.Character=ch
1253
	wait(6)
1254
	warn("100%")
1255
end;
1256
1257
Respawn = function()
1258
	local ch = game.Players.LocalPlayer.Character
1259
	
1260
	local prt=Instance.new("Model", workspace)
1261
	local z1 =  Instance.new("Part", prt)
1262
	z1.Name="Torso"
1263
	z1.CanCollide = false
1264
	z1.Anchored = true
1265
	local z2  =Instance.new("Part", prt)
1266
	z2.Name="Head"
1267
	z2.Anchored = true
1268
	z2.CanCollide = false
1269
	local z3 =Instance.new("Humanoid", prt)
1270
	z3.Name="Humanoid"
1271
	z1.Position = Vector3.new(0,9999,0)
1272
	z2.Position = Vector3.new(0,9991,0)
1273
	game.Players.LocalPlayer.Character=prt
1274
	wait(5)
1275
	game.Players.LocalPlayer.Character=ch
1276
end;
1277
1278
ChatHUDFunc = function()
1279
	--[[
1280
		Variables
1281
	--]]
1282
	
1283
	local UserInputService = game:GetService("UserInputService")
1284
	local RunService = game:GetService("RunService")
1285
	
1286
	local VRService = game:GetService("VRService")
1287
	 local VRReady = VRService.VREnabled
1288
	
1289
	local Players = game:GetService("Players")
1290
	 local Client = Players.LocalPlayer
1291
	
1292
	local ChatHUD = game:GetObjects("rbxassetid://4476067885")[1]
1293
	 local GlobalFrame = ChatHUD.GlobalFrame
1294
	  local Template = GlobalFrame.Template
1295
	 local LocalFrame = ChatHUD.LocalFrame
1296
	 local Global = ChatHUD.Global
1297
	 local Local = ChatHUD.Local
1298
	
1299
	local Camera = workspace.CurrentCamera
1300
	
1301
	Template.Parent = nil
1302
	ChatHUD.Parent = game:GetService("CoreGui")
1303
	
1304
	--[[
1305
		Code
1306
	--]]
1307
	
1308
	local Highlight = Global.Frame.BackgroundColor3
1309
	local Deselected = Local.Frame.BackgroundColor3
1310
	
1311
	local OpenGlobalTab = function()
1312
		Global.Frame.BackgroundColor3 = Highlight
1313
		Local.Frame.BackgroundColor3 = Deselected
1314
		
1315
		Global.Font = Enum.Font.SourceSansBold
1316
		Local.Font = Enum.Font.SourceSans
1317
		
1318
		GlobalFrame.Visible = true
1319
		LocalFrame.Visible = false
1320
	end
1321
	
1322
	local OpenLocalTab = function()
1323
		Global.Frame.BackgroundColor3 = Deselected
1324
		Local.Frame.BackgroundColor3 = Highlight
1325
		
1326
		Global.Font = Enum.Font.SourceSans
1327
		Local.Font = Enum.Font.SourceSansBold
1328
		
1329
		GlobalFrame.Visible = false
1330
		LocalFrame.Visible = true
1331
	end
1332
	
1333
	Global.MouseButton1Down:Connect(OpenGlobalTab)
1334
	Local.MouseButton1Down:Connect(OpenLocalTab)
1335
	Global.MouseButton1Click:Connect(OpenGlobalTab)
1336
	Local.MouseButton1Click:Connect(OpenLocalTab)
1337
	
1338
	OpenLocalTab()
1339
	
1340
	--
1341
	
1342
	local function GetPlayerDistance(Sender)
1343
		if Sender.Character and Sender.Character:FindFirstChild("Head") then
1344
			return math.floor((Sender.Character.Head.Position - Camera:GetRenderCFrame().p).Magnitude + 0.5)
1345
		end
1346
	end
1347
	
1348
	local function NewGlobal(Message, Sender, Color)
1349
		local Frame = Template:Clone()
1350
		
1351
		Frame.Text = ("[%s]: %s"):format(Sender.Name, Message)
1352
		Frame.User.Text = ("[%s]:"):format(Sender.Name)
1353
		Frame.User.TextColor3 = Color
1354
		Frame.BackgroundColor3 = Color
1355
		Frame.Parent = GlobalFrame
1356
		
1357
		delay(60, function()
1358
			Frame:Destroy()
1359
		end)
1360
	end
1361
	
1362
	local function NewLocal(Message, Sender, Color, Dist)
1363
		local Frame = Template:Clone()
1364
		
1365
		Frame.Text = ("(%s) [%s]: %s"):format(tostring(Dist), Sender.Name, Message)
1366
		Frame.User.Text = ("(%s) [%s]:"):format(tostring(Dist), Sender.Name)
1367
		Frame.User.TextColor3 = Color
1368
		Frame.BackgroundColor3 = Color
1369
		Frame.Parent = LocalFrame
1370
		
1371
		delay(60, function()
1372
			Frame:Destroy()
1373
		end)
1374
	end
1375
	
1376
	local function OnNewChat(Message, Sender, Color)
1377
		if not ChatHUD or not ChatHUD.Parent then return end
1378
		
1379
		NewGlobal(Message, Sender, Color)
1380
		
1381
		local Distance = GetPlayerDistance(Sender)
1382
		
1383
		if Distance and Distance <= ChatLocalRange then
1384
			NewLocal(Message, Sender, Color, Distance)
1385
		end
1386
	end
1387
	
1388
	local function OnPlayerAdded(Player)
1389
		if not ChatHUD or not ChatHUD.Parent then return end
1390
		
1391
		local Color = BrickColor.Random().Color
1392
		
1393
		Player.Chatted:Connect(function(Message)
1394
			OnNewChat(Message, Player, Color)
1395
		end)
1396
	end
1397
	
1398
	Players.PlayerAdded:Connect(OnPlayerAdded)
1399
	
1400
	for _, Player in pairs(Players:GetPlayers()) do
1401
		OnPlayerAdded(Player)
1402
	end
1403
	
1404
	--
1405
	
1406
	local ChatPart = ChatHUD.Part
1407
	
1408
	ChatHUD.Adornee = ChatPart
1409
	
1410
	if VRReady then
1411
		ChatHUD.Parent = game:GetService("CoreGui")
1412
		ChatHUD.Enabled = true
1413
		ChatHUD.AlwaysOnTop = true
1414
		
1415
		local OnInput = UserInputService.InputBegan:Connect(function(Input, Processed)
1416
			if not Processed then
1417
				if Input.KeyCode == Enum.KeyCode.ButtonX then
1418
					ChatHUD.Enabled = not ChatHUD.Enabled
1419
				end
1420
			end
1421
		end)
1422
		
1423
		local RenderStepped = RunService.RenderStepped:Connect(function()
1424
			local LeftHand = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
1425
			
1426
			ChatPart.CFrame = Camera.CFrame * LeftHand
1427
		end)
1428
		
1429
		local CharacterAdded
1430
		
1431
		CharacterAdded = Client.CharacterAdded:Connect(function()
1432
			OnInput:Disconnect()
1433
			RenderStepped:Disconnect()
1434
			CharacterAdded:Disconnect()
1435
			
1436
			ChatHUD:Destroy()
1437
			ChatHUD = nil
1438
		end)
1439
	end
1440
	
1441
	wait(9e9)
1442
end;
1443
1444
ViewHUDFunc = function()
1445
	--[[
1446
		Variables
1447
	--]]
1448
	
1449
	local ViewportRange = ViewportRange or 32
1450
	
1451
	local UserInputService = game:GetService("UserInputService")
1452
	local RunService = game:GetService("RunService")
1453
	
1454
	local VRService = game:GetService("VRService")
1455
	 local VRReady = VRService.VREnabled
1456
	
1457
	local Players = game:GetService("Players")
1458
	 local Client = Players.LocalPlayer
1459
	  local Mouse = Client:GetMouse()
1460
	
1461
	local Camera = workspace.CurrentCamera
1462
	 local CameraPort = Camera.CFrame
1463
	
1464
	local ViewHUD = script:FindFirstChild("ViewHUD") or game:GetObjects("rbxassetid://4480405425")[1]
1465
	 local Viewport = ViewHUD.Viewport
1466
	  local Viewcam = Instance.new("Camera")
1467
	 local ViewPart = ViewHUD.Part
1468
	
1469
	ViewHUD.Parent = game:GetService("CoreGui")
1470
	
1471
	Viewcam.Parent = Viewport
1472
	Viewcam.CameraType = Enum.CameraType.Scriptable
1473
	Viewport.CurrentCamera = Viewcam
1474
	Viewport.BackgroundTransparency = 1
1475
	
1476
	--[[
1477
		Code
1478
	--]]
1479
	
1480
	local function Clone(Character)
1481
		local Arc = Character.Archivable
1482
		local Clone;
1483
		
1484
		Character.Archivable = true
1485
		Clone = Character:Clone()
1486
		Character.Archivable = Arc
1487
		
1488
		return Clone
1489
	end
1490
	
1491
	local function GetPart(Name, Parent, Descendants)
1492
		for i = 1, #Descendants do
1493
			local Part = Descendants[i]
1494
			
1495
			if Part.Name == Name and Part.Parent.Name == Parent then
1496
				return Part
1497
			end
1498
		end
1499
	end
1500
	
1501
	local function OnPlayerAdded(Player)
1502
		if not ViewHUD or not ViewHUD.Parent then return end
1503
		
1504
		local function CharacterAdded(Character)
1505
			if not ViewHUD or not ViewHUD.Parent then return end
1506
			
1507
			Character:WaitForChild("Head")
1508
			Character:WaitForChild("Humanoid")
1509
			
1510
			wait(3)
1511
			
1512
			local FakeChar = Clone(Character)
1513
			local Root = FakeChar:FindFirstChild("HumanoidRootPart") or FakeChar:FindFirstChild("Head")
1514
			local RenderConnection;
1515
			
1516
			local Descendants = FakeChar:GetDescendants()
1517
			local RealDescendants = Character:GetDescendants()
1518
			local Correspondents = {};
1519
			
1520
			FakeChar.Humanoid.DisplayDistanceType = "None"
1521
			
1522
			for i = 1, #Descendants do
1523
				local Part = Descendants[i]
1524
				local Real = Part:IsA("BasePart") and GetPart(Part.Name, Part.Parent.Name, RealDescendants)
1525
				
1526
				if Part:IsA("BasePart") and Real then
1527
					Part.Anchored = true
1528
					Part:BreakJoints()
1529
					
1530
					if Part.Parent:IsA("Accessory") then
1531
						Part.Transparency = 0
1532
					end
1533
					
1534
					table.insert(Correspondents, {Part, Real})
1535
				end
1536
			end
1537
			
1538
			RenderConnection = RunService.RenderStepped:Connect(function()
1539
				if not Character or not Character.Parent then
1540
					RenderConnection:Disconnect()
1541
					FakeChar:Destroy()
1542
					
1543
					return
1544
				end
1545
				
1546
				if (Root and (Root.Position - Camera.CFrame.p).Magnitude <= ViewportRange) or Player == Client or not Root then
1547
					for i = 1, #Correspondents do
1548
						local Part, Real = unpack(Correspondents[i])
1549
						
1550
						if Part and Real and Part.Parent and Real.Parent then
1551
							Part.CFrame = Real.CFrame
1552
						elseif Part.Parent and not Real.Parent then
1553
							Part:Destroy()
1554
						end
1555
					end
1556
				end
1557
			end)
1558
			
1559
			FakeChar.Parent = Viewcam
1560
		end
1561
		
1562
		Player.CharacterAdded:Connect(CharacterAdded)
1563
		
1564
		if Player.Character then
1565
			spawn(function()
1566
				CharacterAdded(Player.Character)
1567
			end)
1568
		end
1569
	end
1570
	
1571
	local PlayerAdded = Players.PlayerAdded:Connect(OnPlayerAdded)
1572
	
1573
	for _, Player in pairs(Players:GetPlayers()) do
1574
		OnPlayerAdded(Player)
1575
	end
1576
	
1577
	ViewPart.Size = Vector3.new()
1578
	
1579
	if VRReady then
1580
		Viewport.Position = UDim2.new(.62, 0, .89, 0)
1581
		Viewport.Size = UDim2.new(.3, 0, .3, 0)
1582
		Viewport.AnchorPoint = Vector2.new(.5, 1)
1583
	else
1584
		Viewport.Size = UDim2.new(0.3, 0, 0.3, 0)
1585
	end
1586
	
1587
	local RenderStepped = RunService.RenderStepped:Connect(function()
1588
		local Render = Camera.CFrame
1589
		local Scale = Camera.ViewportSize
1590
		
1591
		if VRReady then
1592
			Render = Render * VRService:GetUserCFrame(Enum.UserCFrame.Head)
1593
		end
1594
		
1595
		CameraPort = CFrame.new(Render.p + Vector3.new(5, 2, 0), Render.p)
1596
		
1597
		Viewport.Camera.CFrame = CameraPort
1598
		
1599
		ViewPart.CFrame = Render * CFrame.new(0, 0, -16)
1600
		
1601
		ViewHUD.Size = UDim2.new(0, Scale.X - 6, 0, Scale.Y - 6)
1602
	end)
1603
		
1604
	--
1605
	
1606
	local CharacterAdded
1607
	
1608
	CharacterAdded = Client.CharacterAdded:Connect(function()
1609
		RenderStepped:Disconnect()
1610
		CharacterAdded:Disconnect()
1611
		PlayerAdded:Disconnect()
1612
		
1613
		ViewHUD:Destroy()
1614
		ViewHUD = nil
1615
	end)
1616
	
1617
	wait(9e9)
1618
end;
1619
1620
Script()
1621
1622
wait(9e9)