(First post)
The script is just a normal script.
I have a part with an attribute called rockHP. (Which is the parent of this script.)
rock = script.Parent print("test 1") rock:GetAttributeChangedSignal("rockHP"):Connect(function() print("attribute changed") local rockHP = rock:GetAttribute("rockHP") print(rockHP) if rockHP <= 0 then rock:Destroy() end end) print("test 2")
When I manually change it this script doesn't detect anything.
I've tried to find answers online but I couldn't find any that fit my problem.
ur code works fine, the AttributeChangedSignal just doesnt detect when u manually change it. it only detects when something causes the change for example, look at this code:
local rock = script.Parent rock.Touched:Connect(function(hit) --simple touched event script that sets the rockHP to 0 local hum = hit.Parent:FindFirstChild("Humanoid") if hum then rock:SetAttribute("rockHP",0) end end) rock:GetAttributeChangedSignal("rockHP"):Connect(function() --now it detects the change print("attribute changed") local rockHP = rock:GetAttribute("rockHP") print(rockHP) if rockHP <= 0 then rock:Destroy() end end)