How to make a same-server matchmaking for a table?

I am making a card game, and I’m currently trying to set up matchmaking.

There’s a table with 4 chairs, and when 2 or more people sit at it, a timer (BillboardGUI) above the table becomes visible and starts counting down from 30 seconds.
If a player leaves the table during the countdown and the amount of players is now less than 2, the countdown stops (and the gui becomes invisible)
When the 30 seconds end, the game begins. Suppose it’d be the function: StartGame() .

I thought of using Coroutines for the timer, which seems the right thing to do, but I had problems with it such as not being able to close it.

The following script sets up 4 events that fire when the occupant of a chair changes. If there’s no occupant, that means a player has left the table, and it subtracts 1 from the playerCount. If there is a player, it adds 1 to the playerCount.
I don’t know how to continue the script from this

local function MatchMaking()
	local playerCount = 0
	local TimerText = script.Parent.BillboardGui.Timer
	
	TimerText.Visible = false
	
	for i = 1, 4 do -- Set up "Check Chair" functions
		local Chair = script.Parent["Chair"..tostring(i)].Seat

		Chair:GetPropertyChangedSignal("Occupant"):Connect(function()
			if Chair.Occupant == nil then
				playerCount -= 1
			else
				playerCount += 1
			end
			print(playerCount)
		end)

	end
	
	 
end

MatchMaking()

How it’s set up: (each chair is exactly the same except for the name)

1 Like

You know that the dev fourm that when scripting category is in need we are not allowed to make a whole/almost completly scripts. This category is so we can help fix bugs in written code.

1 Like

This is not a plea for a whole script. I made a part of it and asked how to build off of it.

I don’t know how to continue the script from this