So I'm trying to create a queue system, where once a player has touched the entrance of the queue zone they will be added or removed accordingly. It adds players fine, but it never removes them. What's going wrong?
add player function
function addPlayer(player)
if Queue[player] ~= nil then
print("Player already exists")
else
table.insert(Queue, player)
print(player.Name.." added to the queue")
end
end
remove player function
function removePlayer(player)
if Queue[player] ~= nil then
table.remove(Queue, player)
print(player.Name.." removed from the queue")
else
print("Player does not exist")
end
end
the overall Manager
function QueueManager:adjustQueue(player)
if Queue[player] ~= nil then
removePlayer(player)
return false
else
addPlayer(player)
return true
end
end

1 comment
table.remove takes index as the second argument, not the value