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