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

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

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!

1 comment

0

Is the code in a localscript? It has to be in a localscript.

1 answer

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!

11 comments

0

that is the problem it is not a local script

0

If it's not then put what's below... wait let me edit.

0

Done. Write that.

0

nothing happened :(

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

0

What? What's the error!?

0

Just tell me

0

f9 only works for the place owner (you)

0

Besides that place is closed to visitors :~

0

oh it looks like it started woking??!! SOOOO sorry but thank you so much for trying to help! Your the best

0

Please mark this as the answer

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