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:

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

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.

01wait()
02Squirrels = false
03for i,v in pairs(game.Players) do
04    if i > 1 then
05        Squirrels = true
06    end
07end
08if Squirrels == false then
09     -- Do your GUI thingy or something
10end

Hope this helps.

Ad

Answer this question