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

Why do i get local player as nil?

Whenever i try to access the local player i always gets nil as an error but idk why

1 answer

✓ Accepted answer

You are probably trying to get the local player using a server script, which of course will not work.

You can get the LocalPlayer by using a LocalScript and placing it under client-"only" places like StarterGui (Called "PlayerGui" in-game).

local Players = game:GetService("Players");
local LocalPlayer = Players.LocalPlayer;

print("The local player's name is:", LocalPlayer.Name);
--> The local player's name is: WhereAreTheLights

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