Can you check if a player that has joined is the first player to join that game?

What I mean is that, if a user joins a server and they are the only one in that server how would I get that to ignore a script but then anybody that joins after that player will get the script ran (like, I join the server and I’m the first to join that server so it doesn’t run but if I was to join after somebody else did then it would run the script)

You could have a value that’s set to false and change it to true when the first player joins. After doing that you just check the value before running the script

That won’t really work as if 2 people join at basically the same time then the script will be too slow to set the value and then detect that

Fair, but that seems like the easiest way and the chances of 2 people joining at the same time are quite low

I mean does that happen with popular games or not

Well even if they do you can just get the player at the top of the list instead so that there isn’t a huge mix-up

Something like this would work I believe:

game.Players.PlayerAdded:Connect(function()
local number = game.Players:GetChildren()
if #number ~= 1 then
--Enter your Code here
end)
2 Likes

I started a test server and assuming that both windows join at the same time, it should work

Yeah that works, thanks for the help!

1 Like

I thought you wanted the player that joins first

I said that I wanted a script to run for everyone else but the first player that joins which is basically what that does

Yeah. Anyways sorry I couldn’t be of any help (I totally didn’t misread the code btw)