|
| 31 Dec 2014 12:36 AM |
Okay, so, what im trying to do is heal everyone in the server after a short script. But the problem is i don't know how to make everyone in the game into one variable, then healing them all.
while true do local v = game.Players:GetChildren()-ik this part is wrong but how do i write it correctly v.Humanoid.Torso.MaxHealth = math.huge wait(0.5) end
Im stuck on getting everyone in the server into one variable! Please help. (If you want to put non-helping comments, pm me instead, and i'll reply there. This is only for helping :/) |
|
|
| Report Abuse |
|
|
Twistir
|
  |
| Joined: 19 Nov 2009 |
| Total Posts: 12374 |
|
|
| 31 Dec 2014 12:37 AM |
use this
for i,v in pairs(game.Players:GetChildren()) do if v.Character then --This is so if a player is still loading in it wont break v.Character.Humanoid.Health = v.Character.Humanoid.MaxHealth end end |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2014 12:43 AM |
| Just to be safe, you should also make sure the humanoid exists and it is not dead. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2014 03:14 AM |
Didn't work. I think something went wrong with the players part. Okay, let's make it simple. while true do game.Workspace.WingedAbaddon.Humanoid.MaxHealth = math.huge wait(0.1) end
^^ now instead of just healing me, how could you just heal everyone? The script didn't work because it said "Humanoid is not a valid property of Players" or something like that.
while true do for i,v in pairs(game.Players:GetChildren()) v.Workspace.Humanoid.MaxHealth = math.huge wait(0.1) end end
For some reason that wont work, local or not local. |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 31 Dec 2014 03:16 AM |
for _,plr in pairs(game.Players:GetPlayers()) do if plr.Character and plr.Character.Humanoid then plr.Character.Humanoid.Health = 0 end end
there is no need to use while loop with it, for is a loop itself |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 31 Dec 2014 03:19 AM |
never used but
for _,v in pairs(workspace:GetChildren()) do if game.Players:GetPlayerFromCharacter(v) and v:FindFirstChild("Humanoid") then -- wow i didnt use findfirstchild for humanoid in last post, whatever i think its there always until someone removes it v.Humanoid.Health = v.Humanoid.MaxHealth end end |
|
|
| Report Abuse |
|
|
Egzekiel
|
  |
| Joined: 10 Jan 2011 |
| Total Posts: 1079 |
|
|
| 31 Dec 2014 04:22 AM |
^ You complicate yourself too much local peeps=game.Players:GetChildren() for _,v in ipairs(peeps) do if v.Character~=nil then if v.Character.Humanoid.Health>0 then v.Character.Humanoid.Health=v.Character.Humanoid.MaxHealth end end end |
|
|
| Report Abuse |
|
|
Egzekiel
|
  |
| Joined: 10 Jan 2011 |
| Total Posts: 1079 |
|
|
| 31 Dec 2014 04:22 AM |
| Error, pairs instead of ipairs. |
|
|
| Report Abuse |
|
|
| |
|
|
| 31 Dec 2014 10:32 PM |
| and thank you to those 2 others for the help |
|
|
| Report Abuse |
|
|