I want to make an order queue. When someone presses the join button they will wait to get an order. When someone gets an order, they move up the queue. How do I make this?
You can just rely on a table to make a queue but note the script below is very bare bone and wouldn’t handle if a player in the queue leaves before they get to the front of the queue.
local Queue = {} --Create a table to store everyone in the queue
local function GetFirstInQueue()
local player = Queue[1]
table.remove(Queue,1)
return player
end
local function AddPlayerToQueue(player)
table.insert(Queue,player) --If table.insert() doesn't get an index it assigns the new value of the index #Queue+1
end
8 Likes