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