Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to add a check to this script? Please help!

Asked by
xuefei123 214 Moderation Voter
9 years ago

So I am trying to make a mini game game, however I have no clue on how to add a check to see if all players have died, can someone help me?

So here is the script.

01wait(2)
02local select = script.Rounds:GetChildren()
03local h = script:WaitForChild("Status")
04function start()
05    if game.Players.NumPlayers >= 1 then
06        wait(3)
07        wait(1)
08        h.Value = "Choosing gamemode!"
09        local roundchosen = math.random(1, #select)
10        wait(.1)
11        local round = select[roundchosen]
12        print("Chosen round: " .. round.Name)
13        wait(3)
14        if round.Name == "FFA" then
15            FFA()
View all 57 lines...

1 answer

Log in to vote
0
Answered by 9 years ago
01function OnDied()
02for i,v in pairs(game.Players:GetChildren()) do
03if v.Character then
04if v.Character.Humanoid.Health == 0 then
05print("player had died")
06end
07end
08end
09end
10 
11local c = coroutine.resume(coroutine.create(function() OnDied() end))

Add the variable c in the spot you want to check if a player has died, add the function before the main code.

0
Umm so where u do the loop just put local c?? xuefei123 214 — 9y
0
Put the whole local c line *local c = coroutine.resume(coroutine.create(function() OnDied() end))* after line 53 in your script. TheZankonator -2 — 9y
0
Umm so if I just put it there, it will just do the function, how do I make it stop the function if only 1 or 0 people are left? xuefei123 214 — 9y
0
Bump xuefei123 214 — 9y
0
Are all your alive players gonna be in the contestants table? So you want them removed from there when they die too? TheZankonator -2 — 9y
Ad

Answer this question