juanse71
|
  |
| Joined: 12 Jan 2009 |
| Total Posts: 6784 |
|
| |
|
juanse71
|
  |
| Joined: 12 Jan 2009 |
| Total Posts: 6784 |
|
| |
|
|
| 21 Sep 2012 08:48 PM |
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then while true do for i = 100,0,-20 do h.Health = i wait(1) end end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Sep 2012 08:51 PM |
^
That would error at some point |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2012 08:52 PM |
This one is better.
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then while true do for i = 100,0,-1 do h.Health = i wait(0.05) end end end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 21 Sep 2012 08:53 PM |
| Miz, it didn't error for me.. |
|
|
| Report Abuse |
|
|
| |
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Sep 2012 08:57 PM |
"while true do for i = 100,0,-1 do h.Health = i wait(0.05) end "
This would loop over and over and over. So it could error if one I leave so there is no humanoid or too I already died when the loop is starting. It would of been better to say
while h.Health > 0 do --code end
|
|
|
| Report Abuse |
|
|
| |
|
juanse71
|
  |
| Joined: 12 Jan 2009 |
| Total Posts: 6784 |
|
| |
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
| |
|
|
| 21 Sep 2012 09:06 PM |
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then while h.Health > 0 do h.Health = h.Health - 1 wait(0.05) end end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 21 Sep 2012 09:08 PM |
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then while h.Health > 0 do h.Health = h.Health -1 --do spaces count? wait(0.05) end end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 21 Sep 2012 09:09 PM |
@X
No, it is just easier to read with spaces. |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
| |
|