jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 30 May 2015 08:37 PM |
Will a script updated every time a humanoid's health changes with the changed event? game.Player1.Humanoid.Changed:connect(function() print(game.Player1.Humanoid.Health) end) |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 30 May 2015 08:38 PM |
| I think so, why not test it instead? |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 30 May 2015 08:41 PM |
| I have with a health overlay gui. It won't update with the humanoid's health. |
|
|
| Report Abuse |
|
|
| |
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 30 May 2015 08:48 PM |
This script is in a frame in a playergui.
player = game.Players.LocalPlayer MaxHealth = player.Character.Humanoid.MaxHealth;Health = player.Character.Humanoid.Health
player.Humanoid.Changed:connect(function() if Health < MaxHealth then script.Parent.BackgroundTransparency = 1-((.20*Health)/MaxHealth) elseif Health == MaxHealth then script.Parent.BackgroundTransparency = 1 end end)
|
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
| |
|
|
| 30 May 2015 08:57 PM |
Health isn't a member of player. Here is a tutorial for you:
http://wiki.roblox.com/index.php?title=Absolute_beginner%27s_guide_to_scripting |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 30 May 2015 09:01 PM |
I saw that. I changed it to:
local player = game.Players.LocalPlayer MaxHealth = player.Character.Humanoid.MaxHealth;Health = player.Character.Humanoid.Health player.Character.Humanoid.Changed:connect(function() if Health < MaxHealth then script.Parent.BackgroundTransparency = 1-((.20*Health)/MaxHealth) elseif Health == MaxHealth then script.Parent.BackgroundTransparency = 1 end end)
|
|
|
| Report Abuse |
|
|
|
| 30 May 2015 09:39 PM |
Wait for the humanoid to exist. Also use HealthChanged:
humanoid.HealthChanged:connect(function(health) print(health) end) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 30 May 2015 09:49 PM |
try this
local player = game.Players.LocalPlayer local char = player.Character local human = char:FindFirstChild("Humanoid")
human.Changed:connect(function() if human.Health < human.MaxHealth then script.Parent.BackgroundTransparency = 1-((0.20*human.Health)/human.MaxHealth) elseif human.Health == human.MaxHealth then script.Parent.BackgroundTransparency = 1 end end) |
|
|
| Report Abuse |
|
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 30 May 2015 09:52 PM |
@nq no I was just too lazy to add the checks.
local player = game.Players.LocalPlayer local char = player.Character local human = char:FindFirstChild("Humanoid")
if player and char and human then human.Changed:connect(function() if human.Health < human.MaxHealth then script.Parent.BackgroundTransparency = 1-((0.20*human.Health)/human.MaxHealth) elseif human.Health == human.MaxHealth then script.Parent.BackgroundTransparency = 1 end end) end |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 30 May 2015 09:52 PM |
XD
Almost no one knows about HealthChanged eh.
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 09:53 PM |
| You should still be using WaitForChild. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 30 May 2015 09:57 PM |
| No I shouldn't "need" to. I do what I want. |
|
|
| Report Abuse |
|
|
|
| 30 May 2015 09:58 PM |
| Alright well it's a pretty cool non-working script then, but you do what you want. |
|
|
| Report Abuse |
|
|