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

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

Asked by 2 years ago

game.Players.LocalPlayer

doesn't work so IDK

2 answers

Log in to vote
1
Answered by 2 years ago

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.

Ad
Log in to vote
0
Answered by 2 years ago

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!

Answer this question