So I’ve read some forums on how to remove players from a table but none of them seem to work in my situation. How would I go about fixing this.
local Player = game.Players.LocalPlayer
local RepStore = game:GetService("ReplicatedStorage")
PlayersToTeleport = {}
local TournyConfig = RepStore:WaitForChild('TournyConfig')
local TournyClosed = TournyConfig:WaitForChild('Closed')
Debounce = false
Cooldown = false
Reload = false
script.Parent.MouseButton1Down:Connect(function()
if TournyClosed.Value == true then return end
if Debounce == false and Cooldown == false then
Debounce = true
local Char = game.Players:GetPlayerFromCharacter(Player)
local AlreadyInTable = false
-- Now make sure the player isn't already in the array
for _,OtherPlayer in next,PlayersToTeleport do
if OtherPlayer == Player then
AlreadyInTable = true
end
end
if not AlreadyInTable then
-- Add them to the array!
table.insert(PlayersToTeleport,Player)
print(Player.Name .. ':Added')
script.Parent.RemoteEvent:FireServer(Debounce)
script.Parent.TextLabel.Text = 'Leave Tournament'
script.Parent.TextLabel.TextColor3 = Color3.fromRGB(170,0,0)
end
Cooldown = true
wait(5)
Reload = true
print('Can Leave Tournament')
elseif Debounce == true and Cooldown == true and Reload == true then
for _,OtherPlayer in next,PlayersToTeleport do
if OtherPlayer == Player then
table.remove(PlayersToTeleport,Player)
print(Player.Name ..':Left Tourny')
end
end
end
end)