Hello people of the DevForum! I have a question.
I’ve been trying to create a relatively simple queue system, but I have come across a problem.
Here’s some code I decided I’d start off from:
local PlayersToTeleport = {}
local playersinqueue = (#PlayersToTeleport)
TouchBrick.Touched:Connect(function(TouchedPart)
if TouchedPart.Parent:FindFirstChild("Humanoid") then
local Character = TouchedPart.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local AlreadyInTable = false
-- Now make sure the player isn't already in the table
for _,OtherPlayer in next,PlayersToTeleport do
if OtherPlayer == Player then
AlreadyInTable = true
end
end
if not AlreadyInTable then
-- Add them to the table
table.insert(PlayersToTeleport,Player)
end
end
end)
Its probably a really simple thing, but how would I go about making this but on the MouseButton1Click of a image/text button?
Thanks in advance to anyone that replies.
local AlreadyInTable = false
-- Now make sure the player isn't already in the table
for _,OtherPlayer in next,PlayersToTeleport do
if OtherPlayer == plr then
AlreadyInTable = true
end
end
if not AlreadyInTable then
-- Add them to the table
table.insert(PlayersToTeleport,plr)
if playersinqueue == 1 then --because if I was added to the queue there should be 1 player in there right?
print ("lol")-- lol.
end
No errors. No output.
local script:
script.Parent.JoinFrame.Join.MouseButton1Click:Connect(function()
game.ReplicatedStorage.QueueRequest:FireServer()
end)
script in serverscriptservice:
local PlayersToTeleport = {}
local playersinqueue = (#PlayersToTeleport)
game.ReplicatedStorage.QueueRequest.OnServerEvent:Connect(function(plr)
local AlreadyInTable = false
for _,OtherPlayer in next,PlayersToTeleport do
if OtherPlayer == plr then
AlreadyInTable = true
end
end
if not AlreadyInTable then
table.insert(PlayersToTeleport,plr)
end
end)