Advertisement
AreYouMental110

Roblox Vr [go to youtube link]

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