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

When I Play my game I get an error saying attempt to index field 'LocalPlayer' (a nail value) Why?

Asked by
TNTeon -1
6 years ago

when I play my game as a test everything work great, but when I play it as a regular player in roblox I get this error happen. It says

"attempt to index field 'LocalPlayer' (a nail value)"

This is my code

if game.Players.LocalPlayer.Team == game.Teams.Offence then

KingTouch = 9
print(KingTouch)

end

Thank You to whoever helps me!

0
Is the code in a localscript? It has to be in a localscript. UgOsMiLy 1074 — 6y

1 answer

Log in to vote
0
Answered by
OfcPedroo 396 Moderation Voter
6 years ago
Edited 6 years ago

Make sure you replace the LocalScript with a Server Script (the regular one), and write the following:

game.Players.PlayerAdded:connect(function(player)
    repeat wait() until player
    if player.Team == game.Teams.Offence then
        KingTouch = 9
        print(KingTouch)
    end
end)

If it works, please mark as the correct answer!

As always, good scripting!

0
that is the problem it is not a local script TNTeon -1 — 6y
0
If it's not then put what's below... wait let me edit. OfcPedroo 396 — 6y
0
Done. Write that. OfcPedroo 396 — 6y
0
nothing happened :( TNTeon -1 — 6y
View all comments (7 more)
0
you can see the error if you would like, the game is called "King Attack" by TNTeon, touch the king and then press f9 to see the errors, use the portal gun to get around fast TNTeon -1 — 6y
0
What? What's the error!? OfcPedroo 396 — 6y
0
Just tell me OfcPedroo 396 — 6y
0
f9 only works for the place owner (you) OfcPedroo 396 — 6y
0
Besides that place is closed to visitors :~ OfcPedroo 396 — 6y
0
oh it looks like it started woking??!! SOOOO sorry but thank you so much for trying to help! Your the best TNTeon -1 — 6y
0
Please mark this as the answer OfcPedroo 396 — 6y
Ad

Answer this question