Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does line 5 error out? [UNANSWERED]

the error says

Workspace.PlayerJoin.JoinCam:5 attempt to index upvalue 'player' (a nil value)

**heres my script : **

local camera = game.Workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer
local found = Player.Character
if found then
print'character has loaded'
else
while not Player.Character do wait() end
end
game.Players.PlayerAdded:connect(function(plr)
	Player.Character.Humanoid.WalkSpeed = 0 
	wait(5)
	camera.CameraType = "Scriptable"
    camera.CoordinateFrame = CFrame.new(84.8, 5, -17.2)
	Player.PlayerGui.Character.Frame.Visible = true
    wait()
end)

2 answers

✓ Accepted answer

Because the current camera can only be accessed from local scripts.

8 comments

0

Oh and you do player.Character when it should be plr.Character

0

it is a localscript

0

Then don't do a game.Players.PlayerAdded just do Player = game.Players.LocalPlayer or Plr = game.Players.LocalPlayer Character = Player.Character?

0

that won't help me though

0

Why not? That would allow you to access the player, and you could keep Camera = game.Workspace.CurrentCamera

0

I'll try it and see

0

Okay I fixed it to what you said but now it doesn't even set the characters camera

0

Make sure all the variables are spelled right, etc

Also, you forgot brackets around the 'character has loaded' :3

1 comment

0

iirc, you don't NEED them

This discussion is preserved as it was. New answers, comments, and votes are closed.