So, i can't figure out how this would work.... the title says it all. I have a variable that holds all the players and a killer variable that represents a player that was randomly chosen from the Players variable/table.
Would i use a Died event? IDK!
Make an alive variable inside the players, and create a separate script to handle switching it off when their Humanoid.Died
Then create a table, like alive = {}
alive = {} --later in the script for i,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("Alive") then v.Alive.Value = true table.insert(alive, v.Name) end end --this is the part to end it If only one player is alive for time = 1,120 do wait(1) if #alive <= 1 then break end for i,v in pairs(game.Players:GetPlayers()) do if not v.Alive.Value then table.remove(alive, i) end end end
This is just an example of how I do it.
Yes, you would use a Died event, and the variable that holds the players should be a table. Whenever a player dies, you would remove them from the table, and after a player dies you should check the length of the table that holds the players and see if the length is equal to one, if so, do your action.