I am making a join game queue so if players want to join the game they touch a part and it puts them in a room with other players and when there is enough players to start the game they get teleported to a new game place. I made this work but it was kinda glitchy and didn’t run very good so I want to redo it better.
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
local char = humanoid.Parent
local Queued = char.Queued
local Waiting = false
if Queued.Value == false and Waiting == false then
Waiting = true
local humanoidroot = char.HumanoidRootPart
humanoidroot.CFrame = telepart.CFrame
wait(1)
Queued.Value = true
Waiting = false
Current = Current + 1
elseif Queued.Value == true and Waiting == false then
Waiting = true
local humanoidroot = char.HumanoidRootPart
humanoidroot.CFrame = telepart2.CFrame
wait(1)
Queued.Value = false
Waiting = false
Current = Current - 1
end
end
end)
How I made this work was I put a bool value inside of every character and if they joined the queue it would be true and if they left it would be false. There are multiple problems with the current script so I was wondering if anyone has any other ideas on how I could do this.