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

Question about waiting for player?

I am having problems lately with my scripts because I have to add a wait before using my scripts. I was wondering if there was a way to wait for the player to load before the script starts.

I think it would start like this:

repeat wait() until

After until, I have no idea what comes next. Help?

2 answers

✓ Accepted answer

You need to wait (usually) for the presence of their Character (since this is one of the last things to load).

player = game.Players.LocalPlayer -- Don't have to wait for this!

repeat
	wait()
until player.Character
-- Do have to wait for their Character!

2 comments

0

Workspace.Script:2: attempt to index global 'player' (a nil value)

1

This is for a LocalScript...

local player = game.Players.LocalPlayer
repeat wait() until player.Character

Similarly, you can replace line 2 with this:

repeat wait() until player.Character~=nil

4 comments

0

Player is not a valid member of DataModel.

0

Must be in a LocalScript in the StarterGui/StarterPack.

0

You do not need to wait for LocalPlayer. You do need to wait for their Character. In addition, THIS CODE WON'T WORK. You aren't recomputing player so the condition will never change.

0

Edited my answer. Thanks Blue.

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