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

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

Asked by
KordGamer 155
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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

0
Okay, thanks. KordGamer 155 — 8y
Ad

Answer this question