The game I’m working on will require a queue system, as 2 players enter a 1v1 scenario in front of all other players in the server. One player will challenge another, and should the other accept, it will place them into a queue to be given their match. I was about to try and take a shot at this by myself before I realized that the way I’m attempting this is probably not the best, and will be a mess by the end of it, so I’d like some input and advice beforehand.
local battleQueue = game.ReplicatedStorage.BattleQueue
local queue = {
["Position 1"] = 1,
["Position 2"] = 2,
["Position 3"] = 3,
["Position 4"] = 4,
["Position 5"] = 5,
["Position 6"] = 6,
["Position 7"] = 7,
["Position 8"] = 8,
["Position 9"] = 9,
["Position 10"] = 10,
}
battleQueue.OnServerEvent:Connect(function(Player, name)
print("Adding players to queue")
end)
There will be 20 players per server, so there should, at most, be 10 positions considering that it will always be a 1v1. Passed on variables are as follows: Player being the player who challenged the other, and name being the player who accepted the challenge.
My idea was to try and assign both players to one variable, then assign that variable a position in the queue. This would require an automated variable assignment, which I’m honestly unsure of how to do just yet, although I am thinking of using math.random for a range of 1-10. Either way, once the variable has been assigned it would replace the string “Position (number)” with said variable, with the value being position in the queue.
Would there be a simpler way to go about this? Please let me know. If this is a good way of doing it, how could I automate variable assignment for the two players?