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: Changed()

Previous Thread :: Next Thread 
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
21 Dec 2011 02:54 PM
In the changed event of a humanoid, how would you check if the property is health and if so, what the value of it is.

This is what I've got so far:

script.Parent.Parent.Humanoid.Changed:connect(function(property)
if property=="Health" then

end
end)
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
21 Dec 2011 02:55 PM
Y u no use the HealthChanged event?
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
21 Dec 2011 02:55 PM
Your code is correct. The first argument of the function is a string of the property being changed.
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
21 Dec 2011 02:58 PM
Oh yeah, HealthChanged. If i use healthChanged, how would I know how much health the humanoid has?
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
21 Dec 2011 03:06 PM
HealthChanged returns the health as argument.
Report Abuse
TheNewScripter is not online. TheNewScripter
Joined: 02 Mar 2010
Total Posts: 2432
21 Dec 2011 03:08 PM
Or... you could just say...

    Humanoid.Changed:connect(function(property)
        if property == "Health" then
            local NewHealth = Humanoid.Health
            -- asdf goes here
        end
    end)

Or if you want to be fancy, use HealthChanged. I am old fashion, so I prefer to use .Changed.
Report Abuse
Pyzothon is not online. Pyzothon
Joined: 26 Oct 2011
Total Posts: 822
21 Dec 2011 03:09 PM
humanoid.HealthChanged:connect(function(newValue)
    print("The new health is "..newValue)
end)

Pyzothon, novice scripter/programmer.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
21 Dec 2011 03:10 PM
The argument in HealthChanged is the current health

­<'+1 Post. Ujelly?'>
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