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
|
  |
| Joined: 26 Jul 2016 |
| Total Posts: 59 |
|
|
| 13 Nov 2016 10:48 AM |
| You hear that? Sounds like a 'bump'. |
|
|
| Report Abuse |
|
|
EeveeVe
|
  |
| Joined: 26 Jul 2016 |
| Total Posts: 59 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 22 Feb 2009 |
| Total Posts: 1343 |
|
| |
|
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
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 13 Nov 2016 11:43 AM |
oooooor "Health: " .. math.ceil(Humanoid.Health) |
|
|
| Report Abuse |
|
|