|
| 02 May 2014 03:37 AM |
while wait() do script.Parent.Parent.Parent.Character:WaitForChild("Health"):Destroy() end
script.Parent.Parent.Parent.Character:WaitForChild("Humanoid").Running:connect(function(speed) if speed > 0 then return else a = script.Parent.Parent.Parent.Character:WaitForChild("Humanoid") if a.Health > 0 and a.Health < 100 then while wait(1) do a.Health = a.Health + 1 end end end end)
[ Xzavion War-Chief ] - [ TSC Imperator ] |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:49 AM |
| WaitForChild blocks until the child appears, don't throw it around so often. The script may error less, but it will still stop working, except with no output because it just waits forever. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:55 AM |
Okay, got that..
script.Parent.Parent.Parent.Character:WaitForChild("Humanoid").Running:connect(function(speed) if speed > 0 then return else a = script.Parent.Parent.Parent.Character:WaitForChild("Humanoid") if a.Health > 0 and a.Health < 100 then while wait(1) do a.Health = a.Health + 0.1 end end end end)
Now the problem is, when I start walking again, the "While wait(1) do" function doesn't stop, it keeps regening the health..
[ Xzavion War-Chief ] - [ TSC Imperator ] |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 02 May 2014 04:02 AM |
break it after something happens
literally use 'break' |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:02 AM |
| Put the if statement inside the loop. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:11 AM |
@Azarth Where would I put the break? I put the break after the while wait(1) do loop, but that just made it stop when I stop walking.
[ Xzavion War-Chief ] - [ TSC Imperator ] |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:12 AM |
Swap these two lines:
if a.Health > 0 and a.Health < 100 then while wait(1) do |
|
|
| Report Abuse |
|
|