AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 25 Aug 2014 05:38 PM |
I'm having trouble with using the NumberValue changed property. The output states that line 1 is the problem, because I don't know how to properly get the character from players like this. Any help is appreciated. (This is a blood gui)
script.Parent.Parent.Character.Humanoid.NumberValue.Changed:connect(function(Val) print ("1st line done") if string then if script.Parent.Parent.Character.Humanoid.Health < 20 then script.Parent.Visible = true else script.Parent.Visible = false end end end) |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 25 Aug 2014 05:42 PM |
| Also, I'm not doing while wait() do because I want to prevent lag. |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2014 06:05 PM |
Output? print(script.Parent.Parent.ClassName) |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 25 Aug 2014 06:06 PM |
After some testing, I've come to this, still stuck on first line. I'll post output
script.Parent.Parent.Parent.Parent.Character.Humanoid.Health.Changed:connect(function(Val) if string then if script.Parent.Parent.Parent.Parent.Character.Humanoid.Health < 20 then script.Parent.Visible = true else script.Parent.Visible = false end end end)
Output: Players.Player1.PlayerGui.ScreenGui.ImageLabel.BloodScript:1: attempt to index field 'Health' (a number value) |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2014 06:08 PM |
... You don't hook a changed event to the health property of humanoid, rather the object itself.
http://wiki.roblox.com/index.php?title=Changed_(Event) |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
| |
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 25 Aug 2014 06:14 PM |
I'm just trying different things
I'm trying to use .Changed to prevent lag could arise with a wait() or wait(1) |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2014 06:18 PM |
"rather the object itself"
Workspace.Player1.Humanoid.Changed:connect(function(Change) print(Change ,": " ,Workspace.Player1.Humanoid[Change]) end) |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2014 06:21 PM |
| There is a HealthChanged Event of Humanoid if I'm not mistaken. |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2014 06:24 PM |
| Ahh, right, forgot about that. |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 25 Aug 2014 07:17 PM |
This is the current script (That works). To increase efficiency, bugs, etc, should I edit it to the HealthChanged?
script.Parent.Parent.Parent.Parent.Character.Humanoid.Changed:connect(function(Changed) if script.Parent.Parent.Parent.Parent.Character.Humanoid.Health < 25 then script.Parent.Visible = true else script.Parent.Visible = false end end) |
|
|
| Report Abuse |
|
|