I made a mini game script for two random players going against another, and I'm not going to give the whole script to bore you out, but I will give you the main section. Usually when a player dies, the other player wins. But what I realize was that when a player leaves during the round, the game ends up breaking. I do not know how to make a script line where if a player leaves the other gets victory, and help?
repeat
wait()
if f1.Character.Humanoid.Health <= 0 then--declare winners
winner = f2
elseif f2.Character.Humanoid.Health <= 0 then
winner = f1
end
until winner ~= nil
if winner:findFirstChild("leaderstats") then
if winner.leaderstats:findFirstChild(stat) then
winner.leaderstats[stat].Value = winner.leaderstats[stat].Value + 1
end
end
m.Value = "The winner is... "..winner.Name.."!"
wait(1)
game.Workspace.Crowd1:Play()
wait(10)
game.Workspace.Crowd1:Stop()
wait(1)
winner.Character:BreakJoints()
winner = nil
end
