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 » Scripting Helpers
Home Search
 

Re: NumberValue.Changed

Previous Thread :: Next Thread 
AntiFiter is not online. 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 is not online. 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
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
25 Aug 2014 06:05 PM
Output?
print(script.Parent.Parent.ClassName)
Report Abuse
AntiFiter is not online. 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
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
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 is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Aug 2014 06:09 PM
I know, I'm pathetic

;(
Report Abuse
AntiFiter is not online. 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
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
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
HumanXerxes is not online. HumanXerxes
Joined: 17 Apr 2011
Total Posts: 1351
25 Aug 2014 06:21 PM
There is a HealthChanged Event of Humanoid if I'm not mistaken.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
25 Aug 2014 06:24 PM
Ahh, right, forgot about that.
Report Abuse
AntiFiter is not online. 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
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