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 » Scripters
Home Search
 

Re: Having troubles working a Health Bar, can you help me?

Previous Thread :: Next Thread 
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 10:44 AM
I have all the framing set and what not. I just need some help with the scripting. I don't need the health bar to move or anything when the player gets hurt. I have it set up like this, "Health: 100". I just need the '100' to go down when the player is injured.

Thank you for taking your time to read this.
Report Abuse
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 10:48 AM
You hear that? Sounds like a 'bump'.
Report Abuse
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 10:52 AM
Bump.
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
13 Nov 2016 10:54 AM
local script inside of text box:


local player = game.Players.LocalPlayer -- This references the player. Should only be used in local scripts
local char = player.Character or player.CharacterAdded:wait() -- references the character
local hum = char:WaitForChild('Humanoid') -- references the humanoid

hum.HealthChanged:connect(function() -- fires when health changes
script.Parent.Text = hum.Health -- changes the text to the health
end)
Report Abuse
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 11:03 AM
Thank you so much for the help! But, is there anyway I can have it display like this, "Health : 94" or "Health : 37"? I wanna try and keep that "Health :" in there. If not, that's ok. Thank you so much.
Report Abuse
Gaming_Vortex is not online. Gaming_Vortex
Joined: 26 Jan 2013
Total Posts: 544
13 Nov 2016 11:05 AM

local player = game.Players.LocalPlayer -- This references the player. Should only be used in local scripts
local char = player.Character or player.CharacterAdded:wait()
local hum = char:WaitForChild('Humanoid') -- references the humanoid

hum.HealthChanged:connect(function() -- fires when health changes
script.Parent.Text = 'Health: '..hum.Health -- changes the text to the health
end)


-- this will include the Health: part.


Report Abuse
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 11:09 AM
Wow, you guys are very helpful. Thank you so much. I don't wanna keep bothering you with questions, but this is my last one. When I am regaining Health, the numbers don't round up. So it looks like this, "78.004348210023". Is there a way I can fix that?
Report Abuse
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 11:18 AM
If not, that's ok. But thank you for all the help, it means a lot.
Report Abuse
EeveeVe is not online. EeveeVe
Joined: 26 Jul 2016
Total Posts: 59
13 Nov 2016 11:37 AM
Eeeeeek, I did it! I fixed it! Thank you both for all your help.
Report Abuse
jody7777 is not online. jody7777
Joined: 22 Feb 2009
Total Posts: 1343
13 Nov 2016 11:41 AM
math.round


FOR THE CAUSE
Report Abuse
jody7777 is not online. jody7777
Joined: 22 Feb 2009
Total Posts: 1343
13 Nov 2016 11:41 AM
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end

idk why i said math.round o_O


FOR THE CAUSE
Report Abuse
SurKipper is not online. SurKipper
Joined: 25 Dec 2011
Total Posts: 435
13 Nov 2016 11:43 AM
oooooor
"Health: " .. math.ceil(Humanoid.Health)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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