Can I pls get some closure? THE PROBLEM IS IN LINE 10
Here is the script:
local Table = {}
local MaxPlayers = 2
local ts = game:GetService("TeleportService")
game.Workspace.Pad1.CanTouch = true
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "PLAYERS: 0/2"
local inQueue = false
script.Parent.Touched:Connect(function(TouchedPart)
if TouchedPart.Parent:FindFirstChild("Humanoid") and not inQueue then
inQueue = true
local Character = TouchedPart.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
table.insert(Table,Player)
if #Table < 2 then
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "PLAYERS: 1/2"
repeat
wait(0.01)
until #Table > 1
else
if #Table > 1 then
game.Workspace.TwoPlayerPlayers.Value = 1
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "PLAYERS: 2/2"
wait(2)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 10"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 9"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 8"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 7"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 6"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 5"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 4"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 3"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 2"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING IN: 1"
wait(1)
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "TELEPORTING NOW"
wait(2)
game.Workspace.TwoPlayerPlayers.Value = 0
game.Workspace.TWOPLAYERQUEUE.Overhead.BillboardGui.Frame["PLAYERS&TELEPORTING"].Text = "PLAYERS: 0/2"
Table = {}
end
end
end
end)

4 comments
I put the variable into the funtion and it addded the player into the table multiple times
Yeah, I realized my error and don't do that lol. Could you explain the issue a little more?
It basically makes the variable true for the entire lobby when the function is fired off.
Where is this script located?