local rp = gt[math.random(1,#gt)] local gt = game.Players:GetPlayers() for _,Player in pairs(gt) do -- For all the players if not Player == rp then -- If player is not the randomly selected player if Player.Humanoid ~= 0 then --what im trying to do is if all the players are dead then it will restart the script... h.Text = "NOOOOO " script.Archivable = false script.Disabled = true wait() script.Disabled = false script.Archivable = true end end end
but it doesnt seems to work, so i'd hope one of you guys could try helping me
local gt = game.Players:GetPlayers() --You had rp, before gt was defined. local rp = gt[math.random(1,#gt)] local function findAll() for _,Player in pairs(gt) do -- For all the players when the script first grabbed them. if Player ~= rp then -- If player is not the randomly selected player if Player.Character.Humanoid.Health ~= 0 then -- return true end end end return false end --This should be run every time someone dies, via something like your leaderboard script. if findAll() then print("Someone is still alive.") else print("Everyone is dead") h.Text = "NOOOOO " --This is very bad vvvv script.Archivable = false script.Disabled = true wait() script.Disabled = false script.Archivable = true end