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

Gui will follow remove function with 1 player but not 2 players?

Asked by
KenzaXI 166
9 years ago

Right so, the gui is meant to be removed when it for fills it's purpose, and it will remove BUT only when there is 1 player in the server, This is a localscript within a TextButton, The Gui gets clones to the lighting by a normal script which in my workspace. Thanks for your help. Gui Clone script:

1game.Players.PlayerAdded:connect(function(player)
2    game.Workspace.Map1.ScreenGui:Clone().Parent = game.StarterGui
3end)

Gui script:

01repeat wait() until game.Players.LocalPlayer
02local i = script.Parent
03local map = workspace.Map1.Stadium.sa
04local gui = script.Parent.Parent.Parent
05local tele1 = game.Workspace.Map1.Tele1
06function onButtonClicked()
07    local plr = game.Players.LocalPlayer
08    local character = plr.Character
09if (plr and character ~= nil) then
10    character:MoveTo(map.Position) 
11    tele1:Clone().Parent = plr.PlayerGui
12    script.Parent.Parent.Parent:Destroy()
13end
14    end
15i.MouseButton1Down:connect(onButtonClicked)

1 answer

Log in to vote
0
Answered by
woodengop 1134 Moderation Voter
9 years ago

You could save the players in a table or use the NumPlayers property.

01-- usage of Tables
02 
03local PlayersOnline = {}
04 
05game.PlayersAdded:connect(function(player) -- player Argument
06    table.insert(PlayersOnline,player)
07    if #PlayersOnline < 2 then
08        -- code
09    end
10end)
11 
12-- usage of NumPlayers
13 
14if game.Players.NumPlayers < 2 then
15    -- code
16end
0
I rarely use tables because I don't get how to use them, Can you help me use this table please? KenzaXI 166 — 9y
0
Like a walkthrough on how it works? woodengop 1134 — 9y
0
Yeah KenzaXI 166 — 9y
Ad

Answer this question