Advertisement
Guest User

VR Script

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