|
| 24 Oct 2014 10:02 PM |
The thing works, but if you don't spam-click it, and your health drops below 25 once, it supplies + 20 to the IntValue (dubbed Adrenaline). However, after the ROBLOX health starts raising (I don't know if this is the problem, all I know is that it happens around this time), it supplies the IntValue with plenty more than the initial 20 points it was supposed to supply.
humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid") adrenbar = script.Parent
humanoid.HealthChanged:connect(function() if humanoid.Health < 25 and adrenbar.Adrenaline.Value < 65 then adrenbar.Adrenaline.Value = adrenbar.Adrenaline.Value + 20 end end) |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Oct 2014 10:03 PM |
| Yeah, when they heal the healthchanged event is invoked. |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2014 10:04 PM |
| There are no other scripts to my knowledge interfering, because once I abstracted this script from my game, no changing of the Adrenaline or adrenbar occurred. |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2014 10:06 PM |
I tried debounce, didn't help much.
@cnt: oh. yeah... okay. right. how to fix this so that the function is only called when the player is losing health, and that it only is called once until the health is above 25? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Oct 2014 10:07 PM |
You can do something like:
humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid") adrenbar = script.Parent lastHealth = humanoid.Health;
humanoid.HealthChanged:connect(function(nh) if nh < lastHealth and humanoid.Health < 25 and adrenbar.Adrenaline.Value < 65 then adrenbar.Adrenaline.Value = adrenbar.Adrenaline.Value + 20 end lastHealth = nh; end)
|
|
|
| Report Abuse |
|
|
|
| 24 Oct 2014 10:07 PM |
| Nvm, just how to get it to trigger only if the player is losing health, i can do the other part. |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Oct 2014 10:14 PM |
| Nevermind, my method of repeating waiting until health is above 25 is not working. So I still need that last piece for waiting. :p |
|
|
| Report Abuse |
|
|
| |
|
| |
|