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

Players Alive/Players Dead function?

Asked by 8 years ago

A few hours ago I asked a question saying 'How do I make a function so that if all players are dead or if 1 person is alive the round ends' and some one help me come out with this:

local wordValue = game.ReplicatedStorage.valueStorage.wordValue
local timeValue = game.ReplicatedStorage.valueStorage.timeValue

function playersCurrentlyPlaying()  
    local playerDead = 0

    for loopTime, loopPlayers in ipairs (game.Players:GetChildren()) do
        if loopPlayers.playValue.Value == 0 then 
            playerDead = 1
        end
    end

    if playerDead == 0 then 
        print 'Players are alive!'
    else
        wordValue = 'All players have died!'
        timeValue = '0:00'
    end
end

It wont work and I'm not a very experienced scripter, so please let me know how or why it is wrong and a way to fix it, thanks!

0
Test it. JamesLWalker 297 — 8y
0
I did, it doesn't work. Vestralix 15 — 8y
0
Instead of setting a value to one, why not loop through and increment the playerDead variable? Then you can check the number of it as you are on line 13. Pyrondon 2089 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Line 15:

elseif playerDead == 1 then
         wordValue = "All players have died!"
         timeValue = "0:00"
end
0
It's still not working, but thank you for sharing this! Vestralix 15 — 8y
Ad

Answer this question