Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago

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?

0
Can’t modify PlayerGui from the server/shouldn’t be. User#19524 175 — 6y
0
Its not in a Server Script. SBlankthorn 329 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

Ad

Answer this question