Advertisement
oatmeal2009

vr

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