Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Players Alive/Players Dead function?

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!

3 comments

0

Test it.

0

I did, it doesn't work.

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.

1 answer

Line 15:

elseif playerDead == 1 then
         wordValue = "All players have died!"
         timeValue = "0:00"
end

1 comment

0

It's still not working, but thank you for sharing this!

This discussion is preserved as it was. New answers, comments, and votes are closed.