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

Why does line 5 error out? [UNANSWERED]

Asked by
Prioxis 673 Moderation Voter
9 years ago

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

Log in to vote
2
Answered by 9 years ago

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

0
Oh and you do player.Character when it should be plr.Character xImmortalChaos 565 — 9y
0
it is a localscript Prioxis 673 — 9y
0
Then don't do a game.Players.PlayerAdded just do Player = game.Players.LocalPlayer or Plr = game.Players.LocalPlayer Character = Player.Character? xImmortalChaos 565 — 9y
0
that won't help me though Prioxis 673 — 9y
View all comments (4 more)
0
Why not? That would allow you to access the player, and you could keep Camera = game.Workspace.CurrentCamera xImmortalChaos 565 — 9y
0
I'll try it and see Prioxis 673 — 9y
0
Okay I fixed it to what you said but now it doesn't even set the characters camera Prioxis 673 — 9y
0
Make sure all the variables are spelled right, etc xImmortalChaos 565 — 9y
Ad
Log in to vote
-2
Answered by 9 years ago

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

0
iirc, you don't NEED them iaz3 190 — 9y

Answer this question