Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why do my first-person arms randomly get deleted?

Asked by
Elyzzia 1294 Moderation Voter
6 years ago
Edited 6 years ago

I have a script to show first person arms, but for some reason, they disappear shortly after the character is spawned. It works perfectly fine in Studio, but on a local server, it starts to act strange.

repeat wait() until game.Players.LocalPlayer.Character
local name = script.Parent.Name
local character = game.Players.LocalPlayer.Character
local camera = workspace.CurrentCamera
game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
character.r.Name = name.."r"
character.l.Name = name.."l"
character[name.."r"].Parent = workspace
character[name.."l"].Parent = workspace
game:GetService("RunService").RenderStepped:connect(function()
    workspace[name.."r"].CFrame = CFrame.new(camera.CFrame * Vector3.new(1, -0.5, 0), camera.CFrame * Vector3.new(0, 0, 100))
    workspace[name.."l"].CFrame = CFrame.new(camera.CFrame * Vector3.new(-1, -0.5, 0), camera.CFrame * Vector3.new(0, 0, 100))
end)
0
anchored? abnotaddable 920 — 6y
0
Shouldn't "workspace" be capitalized? casperfox 0 — 6y
0
^ If it's "game.Workspace" then yes. Otherwise, workspace can be used by itself and it doesn't need to be capitalized. Mayk728 855 — 6y
0
Also, a problem with the script is that "repeat wait() until" doesn't always work when it comes to waiting for the character to load. Try using "wait(1)" instead. Mayk728 855 — 6y

Answer this question