I'm trying to script a block that destroys itself after the IntValue inside of it reaches the number 2. The following code is in a Script which is placed in the IntValue. I included the wait statement in case the problem was just that something didn't load, but that didn't fix it. There are no error messages. Nothing happens in output, so the function just isn't running. The block doesn't destroy itself even when the IntValue reaches 2.
block = script.Parent.Parent
dmg = script.Parent
repeat wait() until dmg ~= nil
dmg:GetPropertyChangedSignal("Value"):Connect(function()
print("changed")
if dmg.Value >= 2 then
block:Destroy()
print("destroy")
else if dmg.Value < 2 then
print("safe")
end
end
end)
Any help is super appreciated.

6 comments
Is there a chance that your repeat wait() is just going on a forever loop?
It's possible. The script doesn't work either way.
put a print outside of the function and test if it works
Anything I print outside of the function works just fine. It's just that the function itself won't go.
then the GetPropertyChangedSignal event isn't firing. Is there another script that changes the value? local script or server script?
Yes, a tool changes the value (I click on the block with the tool and the IntValue changes). It's a local script for the tool. Is that the issue?