Queue v1 | A zone-based player queue module

Queue is a lightweight, flexible queue system for Roblox that lets players join and leave queue zones. Once the required number of players is reached, it automatically starts a countdown and fires events, allowing you to launch matches, teleport players, or trigger any custom gameplay.

Get the model here

-- This constructs a queue from a zone container, and listens for players joining, the countdown ticking, and the countdown finishing
local Queue = require(game:GetService("ReplicatedStorage").Queue)

local container = workspace.A_MODEL_FOLDER_OR_BASEPART

local testQueue = Queue.new(container, {
	maxPlayers = 10,
	minPlayers = 2,
	countdownLength = 15,
    -- Create a whitelist queue on start or initilize it later 
})

testQueue.playerJoined:Connect(function(player)
	print(("%s joined the queue!"):format(player.Name))
end)

testQueue.countdownTicked:Connect(function(secondsLeft)
	print(("Starting in %d..."):format(secondsLeft))
end)

testQueue.countdownFinished:Connect(function()
	local players = queue:getQueuedPlayers()
	-- teleport players, start a round, whatever you need

    -- Remember to reset the queue after to be able to use it again
	queue:resetQueue()
end)

Theres 6 events you can connect too:

testQueue.playerJoined:Connect(function(player)
	print(player.Name, "joined the queue")
end)

testQueue.playerLeft:Connect(function(player)
	print(player.Name, "left the queue")
end)

testQueue.playerRemoved:Connect(function(player)
	print(player.Name, "was forcefully removed from the queue")
end)

testQueue.countdownStarted:Connect(function()
	print("Countdown started")
end)

testQueue.countdownTicked:Connect(function(secondsLeft)
	print("Starting in", secondsLeft)
end)

testQueue.countdownCanceled:Connect(function()
	print("Countdown was canceled")
end)

testQueue.countdownFinished:Connect(function()
	print("Countdown finished")
end)

-- This adds a whitelist to the queue after initialization, so only specific players are allowed to join, and enforces it on anyone already queued
testQueue:setWhitelist({player1, player2})
testQueue:setWhitelistEnabled(true)
-- This manually removes a player from the queue, and separately locks the queue entirely (kicking everyone currently in it)
testQueue:removePlayerFromQueue(somePlayer)
testQueue:setEnabled(false)
-- Theres also a lot of public method's to customize the queue after initialization:
testQueue:setMaxPlayers(5)

testQueue:setMinPlayers(2)

testQueue:setCountdownLength(15)

testQueue:isPlayerWhitelisted(somePlayer) 

testQueue:isPlayerInQueue(somePlayer)

testQueue:isWhitelistEnabled()

etc..

you can also destroy the queue if you know your not going to use it anymore, cleaning up everything the queue has connected to it

testQueue:destroy()

Credit
Big thanks to:
@ForeverHD for ZonePlus, which this module is built on top of
@stravant for the Signal class used for events

End
Queue is free and open source use it, modify it, rip pieces out of it for your own project, whatever’s useful. Credit is appreciated but not required.

Still fairly early, so feedback on the class is appreciated

Creator Hub - Store

1 Like

Waiting for the model to be accepted by roblox