wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 04 Jun 2014 03:49 AM |
Basically I want to see the number of players that are STILL ALIVE Right now i'm using a while loop for each player and game.Players:FindFirstChilding to see if they left the server or not.
I'm pretty sure game.Players.PlayerRemoving wont work in a LocalScript, soo...
The reason I'm not using a server-side script is because there is also another part that'll be too many while loops for a server to handle.
tl;dr. Make this more efficient without PlayerRemoving plz
for i, v in pairs(game.Players:GetPlayers()) do if v.Character then local pp = false counter = counter + 1 v.Character.Humanoid.Died:connect(function() script.Plrs.Value = script.Plrs.Value-1 pp = true end) Spawn(function() while pp do wait() if not game.Players:FindFirstChild(v.Name) then pp = false script.Plrs.Value=script.Plrs.Value-1 end end end) end end |
|
|
| Report Abuse |
|
|
roxmat
|
  |
| Joined: 10 Jun 2011 |
| Total Posts: 66 |
|
|
| 04 Jun 2014 03:57 AM |
Just have something to check if each player has the value "Alive".
So like
for i,v in pairs(game.Players:GetChildren()) do if v.PlayerGui.Value.Value == "Alive" then counter = counter + 1 end if v.PlayerGui.Value.Value == "Dead" then counter = counter - 1 end end
It's not the best. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 04 Jun 2014 04:01 AM |
| That was the other thing I was trying to avoid... but i guess thats a solution... |
|
|
| Report Abuse |
|
|
nomer888
|
  |
| Joined: 13 Feb 2010 |
| Total Posts: 551 |
|
|
| 04 Jun 2014 04:02 AM |
| It could be me at 2:00 AM being tired and all, but I don't see why LocalScripts can't listen to game.Players' events. Have you tried using .ChildRemoved and .PlayerRemoving already? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 04 Jun 2014 04:16 AM |
| its weird but it doesnt work with child/playerremoving |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 04 Jun 2014 04:18 AM |
| Well, its best, but u can make value somewhere, change it in serverside script, then .Changed event local |
|
|
| Report Abuse |
|
|