We all know that before a player can load into a server the script would run first. In my case, I want it to be the opposite. If a player starts a brand new server, I want the main script to wait until a player is fully loaded in and then the scripts can run. One thing I want to look out for is the fact that if someone else joins, the main script would not run again. I found the solution to it by using this piece of code at the top of my Main script:
while wait() do
local players = game.Players:GetPlayers()
if(#players > 0) then
break
end
print("Nope") -- Used to check if this would keep printing until someone fully joined
end
I want to know if there is an easier and faster solution to this.

12 comments
This waits for the event to fire once, then doesn’t wait anymore.
@incapaz That's how the asker wanted, right..?
OP would have to use a loop for it to keep checking.
"One thing I want to look out for is the fact that if someone else joins, the main script would not run again." OP said to only execute it on the first player join.,
What if another player joins? Would the main script still wait for the other person to join? I have not tried it yet. Also, does this method makes sure that it waits until the player has fully joined and is fully loaded?
@Nathan the first person to join is likely OP for testing.
First question, main script only waits for a player to join, when it does, it continues the code. second question, Currently, you can't assure if a player is fully loaded from the server side of prespective. You'll have to go with remote events firing from the client once the client has all the needed asset loaded.
Let me add that to the answer as well..
@incapaz, it's what the OP wanted. OP wants a script to be executed when a player has joined and fully loaded ONCE. When any other joins, he does not want it to be executed.
@Nathan What is the "Content Provider"? It's the first I am seeing of it
On the client, content provider is ... a content provider. the RequestQueueSize tells how much assets are still being queued on the client. In this case, it waits until it's 0, which means all needed assets are loaded.
Interesting. This will be useful later on. Thank you for your answer