Detecting attribute changes using CollectionService tags on instances works fine initially:
taggeditem:GetAttributeChangedSignal(attributeName):Connect(function()…
However, when cloning a tagged item from ReplicatedStorage, the GetAttributeChangedSignal function does not appear to detect attribute changes.
When cloning an instance events dont replicate. You’ll need to reassign a function to the event that :GetAttributeChangedSignal() returns once you clone the tagged item.
local TagS = game:GetService("CollectionService")
function setupTagged(instance)
--do stuff, setup up events, attributechangedisgnal, etc.
end
for _, instance in pairs(TagS:GetTagged(DA_TAG)) do
setupTagged(instance)
end
TagS:GetInstanceAddedSignal(DA_TAG):Connect(setupTagged)
this way all things that are tagged when the game runs, as well as things that are tagged later (or are cloned from tagged items later) get set up.