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: HealthChanged Event

Previous Thread :: Next Thread 
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
06 Jun 2013 12:16 PM
I am trying to make it where my health bar will decrease in size as the health number actually decreases in value, yet the bar does not wish to move is it should. I know my declarations of the humanoid are fine along with the location of the frame as it returns no errors, but it does not seem to want to work. The number on the health bar " 100/100 " changes whenever I lose health, but the bar doesn't want to move/resize. Here is the script I am using to attempt this:

-----


repeat wait() until script.Parent.Parent.Parent.Parent.Character.Humanoid
healtha = script.Parent._healthLabel
h = script.Parent.Parent.Parent.Parent.Character.Humanoid


while true do
healtha.Text = "HP: "..math.floor(h.Health).."/"..math.floor(h.MaxHealth)..""
wait(.1)
end

function new(health)
print("MADE IT 2 FUNC")
local bar = script.Parent._health
bar.Size = UDim2.new(0, (h.Health/h.MaxHealth)*150, 0, 19)
end


function change(health)
new(health)
end



h.HealthChanged:connect(change)



-----

If you know a solution to this or if you can guide me in a better direction, I would very much appreciated it!

Thank you
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 12:18 PM
"HealthChanged" is not a valid trigger
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 12:19 PM
nvm bad answer
Report Abuse
Hippalectryon is not online. Hippalectryon
Joined: 17 Mar 2013
Total Posts: 45
06 Jun 2013 12:19 PM
Just paste the error there
Report Abuse
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
06 Jun 2013 01:23 PM
As stated in the OP, no error is returned. It looks fine to me, but something isn't working correctly. I added in the print("MADE IT 2 FUNC") to check if it was even making it to THAT function through the connection, but that doesn't even show either. This means there is something wrong with the connection, but I don't see anything wrong.

Report Abuse
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
06 Jun 2013 02:01 PM
I just found out what the error was, but not sure why it is occurring. The error I get is:

Disconnected event because of exception

I suppose it means there's an error in the connection, but I can't seem to find one.
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