contestants = {} function join() for _,v in pairs(game.Players:FindFirstChild()) do v = contestants(table.insert()) end end game.Players.PlayerAdded:connect(join) game.Players.PlayerRemoving:connect(join) if contestants == 1 then game.StarterGui.ScreenGui.Frame.TextLabel.Text = "test" end
You're using (almost) all incorrect syntax.
To get this to work the way you want, you should rewrite the code like this:
local contestants = {} function join() contestants = game.Players:GetPlayers() -- :GetPlayers() (sometimes just :players()) to get all players in a table. -- Reset the table to just all players. end game.Players.PlayerAdded:connect(join) game.Players.PlayerRemoving:connect(join) wait(0.1) join() -- For debugging mostly when using Play Solo. while true do -- Infinite loop if #contestants == 1 then game.StarterGui.ScreenGui.Frame.TextLabel.Text = "test" else -- If there is less than 1 contestant, it will do this. game.StarterGui.ScreenGui.Frame.TextLabel.Text = "" end wait() end
Also, it's table.insert(table, [index,] value)
, but since I didn't use it in my code, I'm showing it down here.