Attribute changes not detected by CollectionService on cloned instances

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.

Do you create a new signal for the new instance? Sharing your code helps a lot…

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.

Here’s how I usually do it:

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.

Thank you - works like a charm! This line was key:

TagS:GetInstanceAddedSignal(DA_TAG):Connect(setupTagged)
1 Like