So basically I’m making a game spectate gui and everytime a new game starts the table gets players added to a table and if a player dies he gets removed from the table but the thing is when i tested it the wrong player gets removed from the table and idk how to fix it.
heres the code
local plrs = {}
StartEvent.OnClientEvent:Connect(function(plr)
table.insert(plrs, plr)
end)
contestantDeath.OnClientEvent:Connect(function(plr)
table.remove(plrs, plrs[plr])
end)
game.Players.PlayerRemoving:Connect(function(plr)
if localPlayer:FindFirstChild(“Contestant”) then
table.remove(plrs, plrs[plr])
end
end)