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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Health Consistency

Previous Thread :: Next Thread 
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
29 Jul 2013 05:16 AM
I am trying to make a monster for my friend's RPG collab game. And I want the Name of the monster to be somewhat like this: Monster: 100/100
100 being the health and the maxhealth
I want them to auto update every .1 seconds so that it would display their health.

I tried the following code but it didn't work. I put it in a model with humanoid and a head

parent = script.Parent
health = parent:findFirstChild("Humanoid").Health

while true do
wait(.1)
parent.Name = "Monster: "..health.."/".."100"
end
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
29 Jul 2013 05:32 AM
Hell no. Don't do loops for this kind of thing.

function updateHealth()
health = script.Parent:FindFirstChild("Humanoid").Health
maxhealth = script.Parent:FindFirstChild("Humanoid").MaxHealth
script.Parent.Name = "Monster: " .. health .. "/" .. maxhealth
end

script.Parent:FindFirstChild("Humanoid").changed:connect(updateHealth)

I am reborn as an ocelot. You disapprove.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 05:43 AM
@DrWaffler:

C'mon bro, use Humanoid.HealthChanged(float health)
Report Abuse
DrWaffler is not online. DrWaffler
Joined: 16 Sep 2011
Total Posts: 4248
29 Jul 2013 05:46 AM
O.O

wat.

how long have we

but that was

who did

wat.

I am reborn as an ocelot. You disapprove.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
29 Jul 2013 06:24 AM
Probably since Humanoids...
Report Abuse
velibor is not online. velibor
Joined: 24 Nov 2009
Total Posts: 1003
29 Jul 2013 06:26 AM
The Changed event exist for a long time, you know ;)
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
29 Jul 2013 07:38 AM
THANK YOU!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
29 Jul 2013 09:11 AM
POOPPOO

HealthChanged =
Changed (prop == "Health"

WUT IF U WANNT DETECT MAXHEALTH NAB?!
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