Sadly Roblox doesn’t error yet with functions like GetAttributeChangedSignal, so I never knew I was doing it wrong.
Original Problem
I can’t believe this is not a feature. I don’t know if I am doing anything wrong but I am making a Client Handler that requires this attribute detection. After seeing that it wasn’t working I decided to test every part of the code apart and I found out a client can’t detect when the server makes a change:
--Client
local myPart = game:GetService("ReplicatedStorage"):WaitForChild("Part");
myPart:GetAttributeChangedSignal("test", function()
warn("Yes, it detected it!");
end);
print("Listening!");
“Listening!” prints first and then “Fired it!” prints next. However, “Yes, it detected it!” never prints. Is there a way I can detect these changes without doing a loop or using remotes? Thanks.
Workaround identified: For this situation I can just use a BoolValue since the .Changed event does fire when changed in the server. However, I would love if we would get the same for attributes since well… It just makes sense.
Note: Using :GetPropertyChangedSignal() also works which doesn’t make any sense to me since :GetAttributeChangedSignal() should also work using this logic
This is weird, I’ve been working with attributes for a long time, but I have encountered this just now. I can’t imagine it was not a feature from the start, I want to think that it broke. Bump
local weapon = script.Parent
--- Listen for one specific attribute change
weapon:GetAttributeChangedSignal("ReloadTime"):Connect(function()
print(weapon:GetAttribute("ReloadTime"))
end)
-- Listen for any attribute change on the instance
weapon.AttributeChanged:Connect(function(attributeName)
print(attributeName, weapon:GetAttribute(attributeName))
end)
@Rabbit_Lord@FuneeDev You are right guys, I tested this exact code and it works. Some unexpected behavior was happening in my game, and I thought its a bug with the attribute feature itself, but has turned out to be my fault. Thanks for the help!