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

Does Players().LocalPlayer wait for the player to be created if the player doesn't exist yet?

For example, when I put a script in ReplicatedFirst and type in game:GetService("Players").LocalPlayer, does the code wait for the player to load in? I just need clarification because I tested this earlier and the code doesn't throw an error.

2 comments

0

What kinda script is this

0

There's no need to wait for the local player. Local scripts only run once the player has loaded in.

2 answers

No, that piece of code alone does not wait for the LocalPlayer, it just locates them. If you want to actually wait for the player, then do this:

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait()

You can also use a function

game.Players.PlayerAdded:Connect(function()

But just don't forget to put end like this at the end of the script to close the function :

end)

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