But would it be possible to do this from a server script?
Yes, you can fire a RemoteEvent from the server to tell the client to disable controls.
If two people enter the queue they stack on each other.
As for this problem, you’d have to come up with some way of keeping track of the players in the queue.
You can set up different points where players will stand in the queue like this:
And then represent the queue as an array, so you can use that in your script, where the index is the position in queue (so 1 is the front or vice versa), and the value is the the player that is currently standing in that position, with 0 being no one.
local queue = {
[1] = 0,
[2] = 0,
[3] = 0,
[4] = 0,
[5] = 0,
}
And from there, you can manipulate the queue - I might personally suggest three functions: adding a player to the queue, removing a player from the queue, and updating the queue.
Here’s an example of what I might write for adding a player to the queue. Take a look at my comments ~
local function AddToQueue(player, humanoid)
--[[
Creating a variable to store what 'node' to move the player to.
It's being initialised as 0, as we don't know where the next
available free space for the player to move to.
]]
local node = 0
--[[
Looping through the queue, if the value (where the player
is stored) is 0, then we know that the position has no
one there, so we can set our variable `node` to be the
node we just found in the loop.
]]
for index,value in ipairs(queue) do
if value == 0 then -- If empty
node = index -- Set `node` to the empty one we've just found
break -- Stop checking, since we've found a free spot
end
end
--[[
Once we've looped through the queue, first check if
we found an available spot - if we didn't then `node` will
still be 0, like we first defined it as. If it isn't 0,
then we want to set the node to be occupied by the new player,
and then move the humanoid to that position.
]]
if node ~= 0 then -- If there is a free spot
queue[node] = player -- Set that spot to the new player
humanoid:MoveTo(nodes[node].Position) -- Move the humanoid (reference to the part's position)
else
-- Queue is full!
end
end
This is the result:
There isn’t no right answer, but this is how I would go about it.