Waiting For Players

I’m trying to make a “Waiting for Players” Surface Gui, but I don’t know where to start. I’ve never made something like this, so any help would be appreciated!

What is this for? and how much players are you waiting for?

1 Like

Let me see if I understand you are saying that you want to make a graphical interface but you don’t know first what the graphical interface is for or what you mean is to make a counter

1 Like

Here is a demo. Maybe this will help you.

My explorer:
image

The script:

-- // VARIABLES
-- / Services
local Players = game:GetService("Players")

-- / Model
local model = script.Parent
local board = model.Board
local touchPart = model.PartToTouch

-- / Graphical User Interface
local gui = board.SurfaceGui
local countLabel = gui.PlayerCountText
local statusLabel = gui.WaitingText

-- / Settings
local MIN_PLAYERS = 1

-- / Arrays
local players = {}

-- // FUNCTIONS
local function updateCount()
	countLabel.Text = tostring(#players).." / "..tostring(MIN_PLAYERS)
end

-- // MAIN
-- Entering & leaving the queue.
Players.PlayerRemoving:Connect(function(player)
	local found = table.find(players, player)
	
	if found then
		table.remove(players, found)
		
		updateCount()
	end
end)

touchPart.Touched:Connect(function(otherPart)
	local player = Players:GetPlayerFromCharacter(otherPart.Parent)
	
	if not player or table.find(players, player) then
		return
			
	else
		table.insert(players, player)
		
		updateCount()
	end
end)

updateCount()

-- Waiting.
local i = 0

repeat
	task.wait(0.5)
	
	local initialText = "Waiting for players"
	local periods = string.format("%."..tostring(i).."s", "...")
	
	statusLabel.Text = initialText..periods
	
	if i < 3 then
		i += 1
		
	else
		i = 0
	end
	
until #players >= MIN_PLAYERS

statusLabel.Text = "Enough players!"

This is not complete, it is just a starter. You can edit the code however you’d like.

3 Likes

I want it to be so that when a group of players (let’s say 10) get teleported to a private server, I don’t want the game to start until all 10 players have joined.

I just tested this, and rearranged different things in the script to fit my already existing game, and this works perfectly, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.