When a user clicks a button they get a tag. The tag has a number on it. The number that is on the tag giver gets increased by 1 each time someone clicks it. Each user can click it once until their tag is used up.
My approach, although it might be a bit excessive would be to have a table, for example called inQueue
local inQueue = {}
To find the position a player should be at you can use #inQueue to return the amount of people in the queue, then specifically insert them at a specific index, for example if there's 4 people in the queue
local inQueue = {"player1","player2","player3","player4"} --#inQueue will return 4 so you can add 1 to it to find where to add the player
The index of the player in the table will be their position.
I'd utilize global values for queue systems. The server will keep one value for the current performer's number, another value for the current available tag.
When the player clicks on the tag, the server creates an ObjectValue with the name of the tag number, whose value is the player's character. (Ex. ObjectValue named "10", its value is "APlayer")
When the current performer's number gets changed, the server searches for an objectvalue with the name that matches the current performer number. Then teleport the player's character.
For the textLabels on the tags, I only need to tostring() everything or just get the instance names. About preventing players from getting tags twice, I'll use a for loop to check the values in queue.
-- The tag giver local inQueueFolder = script.inQueue -- A folder where the values will be stored local availableNumber = script.availableNumber.Value function checkQueue(player) -- Checks if the player is not on the queue for _, inQueue in pairs (inQueueFolder:GetChildren() do if inQueue.Value ~= player then return true end end TagButton.MouseClick:Connect(function(player) if checkQueue(player) then playerValue = Instance.new("ObjectValue") playerValue.Value = player playerValue.Name = tostring(availableNumber) --Created availableNumber = availableNumber+1 -- Changes the number end end)
If You Are Also Planning To Make Like A System To generate A Piano Etc.You Would Want To Have A UI Where You Can Spawn in A Theme. Or Something Like That Here Is A Example Of What You Could Do
local pc = game.Lighting.Model script.Parent.TextButton.MouseButton1Click:Connect(function() pc.Parent = workspace end) script.Parent.Despawn.MouseButton1Click:Connect(function() pc.Parent = game.Lighting end)
i Recommend Putting The Model In Lighting because Usally If You Put It In ReplicatedStorage Or ReplicatedFirst Or ServerStorage etc. It Dissapears