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

How do I get the local player in a "While true do" statement?

game.Players.LocalPlayer

doesn't work so IDK

2 answers

The thing is you wouldn't need to do a True While Loop to even get the LocalPlayer.

Btw you only get the LocalPlayer within a LocalScript if you haven't done so, but

game.Players.LocalPlayer 

gets the player regardless if it's a true statement, unless you deliberately made the code before it false.

You don't need a while true loop to get the LocalPlayer. You just need to make a variable.

Use this if you are in a Local Script:

local Player = game.Players.LocalPlayer

Use this if you are in a Server Script:

game.Players.PlayerAdded:Connect(function(Player)
	--Put anything associated with the Player variable in this function! Anything using the Player variable after the end) will not work!
end)

Hope this helps!

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