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: IntValue in a Part

Previous Thread :: Next Thread 
Papa_Sasquatch is not online. Papa_Sasquatch
Joined: 11 Aug 2016
Total Posts: 5
19 Aug 2016 12:59 PM
Can anyone help me out? I'm trying to make it print("dead") when the IntValue goes below 0. The weird thing is when the < is replaced with > it prints and works.

(Health is an IntValue)This is the script...

local Health = script.Parent.Health
local Part = script.Parent.Parent

if Health.Value <= 0
then
print("dead")
end
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
19 Aug 2016 01:09 PM
Try this:

local Health = script.Parent.Health
local Part = script.Parent.Parent


Health.Changed:connect(function()
if Health.Value <= 0 then
print("dead")
end
end)
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
19 Aug 2016 01:10 PM
that if statement you have will only fire once

it makes sense that it fires when it's greater than 0 because that conditional will run right when the game starts, and of course, the enemy is not going to be hit yet

amanda has what you need


Formerly xXTheRobotXx, add 13,349 posts
Report Abuse
Papa_Sasquatch is not online. Papa_Sasquatch
Joined: 11 Aug 2016
Total Posts: 5
19 Aug 2016 01:13 PM
It works. Thanks.
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
19 Aug 2016 01:16 PM
No problem.

The Changed event fires whenever a property changes in whatever object you are looking at.

So Health.Changed will be triggered every time the Health.Value property changes.

So every time it changes, you check if it's 0, and if it is then run your code.
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