|
| 30 May 2015 11:07 PM |
function checkplayers() for _,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("AliveTag") and v:FindFirstChild("InGameTag") then playersdead = false elseif v:FindFirstChild("InGameTag") then playersdead = true end end end
Instead of checking just one player how would I check all players as a whole? As in, I want to see if all players fit these standards. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 30 May 2015 11:08 PM |
| for i,v in pairs (game.Players:GetChildren()) do |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:09 PM |
| do i replace the v with i? |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 May 2015 11:11 PM |
| It seems like you already are looking through all the players? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 30 May 2015 11:11 PM |
function checkplayers() for i,v in pairs(game.Players:GetChildren()) do if v:FindFirstChild("AliveTag") and v:FindFirstChild("InGameTag") then playersdead = false elseif v:FindFirstChild("InGameTag") then playersdead = true end end end |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:12 PM |
| No i mean, whenever just 1 player fits the standard for "dead", it says that all players are dead |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:14 PM |
function checkplayers() for _,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("AliveTag") and v:FindFirstChild("InGameTag") then return false end end return true end
To return false if any of the players are still alive. |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:16 PM |
| That just instantly put playersdead = true |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:18 PM |
| Replace the returns with playersdead = |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:19 PM |
| I did, see my problem is when a new player joins, it somehow decides that they are representing that all players are dead. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 30 May 2015 11:20 PM |
I have an easier workaround to this.
Just create a boolvalue inside the player when they join that changes to false if they die, then check all the boolvalues in the players. if a boolvalue is true, then those players are alive. |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:23 PM |
| I'll see what I can do with this. Be back in a bit. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 30 May 2015 11:38 PM |
Its easy. I set up everything for you. ----------------------------------------------------------
function onDied(human, player) local playing = player:FindFirstChild("IsPlaying") if not playing then return else if player.IsPlaying.Value == true then player.IsPlaying.Value = false end end end function onRespawn(property, player) if property == "Character" and player.Character then local human = player.Character:FindFirstChild("Humanoid") local p = player local h = human human.Died:connect(function() onDied(h, p) end) end end
game.Players.ChildAdded:connect(function(player) local IsPlaying = Instance.new("BoolValue") IsPlaying.Name = "IsPlaying" IsPlaying.Value = true IsPlaying.Parent = player
while true do if player.Character then break end wait(5) end local human = player.Character:FindFirstChild("Humanoid") human.Died:connect(function() onDied(human, player) end) player.Changed:connect(function(property) onRespawn(property, player) end) IsPlaying.Parent = player end)
---------------------------------------------------------------------------- Then in a separate script after the game is finished just do this
for i,v in pairs(game.Players:GetChildren()) do if v:FindFirstChild("IsPlying") then v.IsPlaying.Value = true end end |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 11:40 PM |
| Use :GetPlayers not :GetChildren |
|
|
| Report Abuse |
|
|
|
| 31 May 2015 04:57 PM |
So how do I use that within this:
timer.Value = 45 for i = 45, 0, -1 do wait(1) timer.Value = timer.Value - 1 status.Value = timer.Value -- HERE "then break end" if won.Value then break end end -- i = end thing
How would I check if all the players are "dead" collectively with that being used. Cause if I used for i,v in pairs and used if v.BLAHBLAH it would only show for that player
|
|
|
| Report Abuse |
|
|
| |
|