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

attempt to index field 'LocalPlayer' (a nil value)? [Help needed ASAP]

I get this error SO OFTEN and never get it fixed! This is the code:

local PlayerService = game:WaitForChild("Players").LocalPlayer.Character
    PlayerService.Health = 0

and the error is in the name.

attempt to index field 'LocalPlayer' (a nil value)

How do i fix this?

1 answer

✓ Accepted answer

The LocalPlayer variable is only available to the Local Script. If you are using a Server Script, this will be nil.

1 comment

0

Okay, thanks.

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