local health = script.Parent.Parent.Health.Value local debounce = false function onHit() if debounce == false then debounce = true health = health - 10 print (health) wait(3) debounce = false script.Parent:Destroy() end end script.Parent.Touched:connect(onHit)
I made this script so that it subtracts 10 from the NumberValue (500), changing it to 490. When the number value is printed through the script, the console says 490, as it should. But when I go into the workspace and look at the actual Value of the NumberValue it still says 500. Shouldn't that change too when the part gets hit?
The reason for this is because you're actually storing the value of health, not health. When you write:
health = health.value health = health - 10
That only changes the value of the variable, not the object's value. You can however do:
health = health health.value = health.value - 10
Which simply stores the object's address, and then changes the value directly.