IntValue.Changed not firing, why's that?
Hello guys,
I have a model, which also has a part, a script and a intValue called health with value defaulted to 100 as direct child.
The script code is:
1 | local entity = script.Parent |
2 | local entityHealth = entity:FindFirstChild( "health" ) |
4 | entityHealth.Changed:Connect( function (newVal) |
Then, when my player sword hits this object, I'm decreasing the value of this intValue with the following code:
01 | local axe = script.Parent |
02 | local blade = axe.Blade |
04 | function onBladeTouch (part) |
05 | local entity = part.Parent |
06 | local health = entity:FindFirstChild( "health" ) |
07 | health.Value = health.Value - 5 |
12 | blade.Touched:Connect(onBladeTouch) |
On my sword script I get the console output of the intValue (health) been constantly decreased, but the entityHealth.Changed event from inside my model (code at the top) never gets fired, so I'm wondering whats wrong.
Thanks in advance.