generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: IntValue changing, not working, idk, help, thanks.

Previous Thread :: Next Thread 
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
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
ScriptGuilder is not online. ScriptGuilder
Joined: 07 Aug 2014
Total Posts: 848
24 Oct 2014 10:03 PM
Use debounce
Report Abuse
cntkillme is not online. 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
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
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
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
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 is not online. 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
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
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
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
24 Oct 2014 10:08 PM
Thanks!
Report Abuse
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
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
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
24 Oct 2014 10:18 PM
hi
Report Abuse
CategoricalSyllogism is not online. CategoricalSyllogism
Joined: 30 Aug 2013
Total Posts: 7680
24 Oct 2014 10:23 PM
Nevermind, I got it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image