Ad
Log in to vote
1

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

Asked by 2 months 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. incapaz 6256 — 2mo
0
Its not in a Server Script. SBlankthorn 305 — 2mo

1 answer

Log in to vote
0
Answered by 2 months ago
Edited 2 months 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