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

Help with making something happen when the first players in a server joins?

Hi, I have a game in Pre-Alpha, and my teleportation script is a bit buggy the first use, so I was wondering if there was somehow I could make a gui pop-up for the FIRST player that joins the server. I tried to do:

game.Players.PlayerAdded:Connect(function(player)
	local Players = game:GetService("Players")
	if Players <= 1 then
		player.PlayerGui:WaitForChild("serverinitiation").TextLabel.Visible = true
	end
end)

But That didn't work. No output either. Any help?

2 comments

0

Can’t modify PlayerGui from the server/shouldn’t be.

0

Its not in a Server Script.

1 answer

For the gui, you'll need a local script. As for the rest, you wasted your time using an event. If you remove the event, the script will start the second the first person joins and the server is created anyways.

As for the local script, it'll be in any character that joins the game, so here's a solution: Either make a Server-Client communication, or just do this in a Local Script.

wait()
Squirrels = false
for i,v in pairs(game.Players) do
	if i > 1 then
		Squirrels = true
	end
end
if Squirrels == false then
	 -- Do your GUI thingy or something
end

Hope this helps.

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