Here’s a prototype that I quickly made which demonstrates the issue.
Local script:
local cs = game:GetService("CollectionService")
cs:GetInstanceRemovedSignal("Tag1"):Connect(function(p)
print(p:GetFullName().. " lost Tag1.")
end)
cs:AddTag(workspace.Part, "Tag1")
Server script:
local cs = game:GetService("CollectionService")
wait(5)
print("Adding server tag.")
cs:AddTag(workspace.Part, "Tag2")
Basically the client will give a tag Tag1
to a part first. Tag1
is not replicated on the server. Later on the Server will grant the tag Tag2
to the part. When Tag2
is being added, the part will lost Tag1
while CollectionService:RemoveTag was not called at all.
According to the Dev Hub:
GetInstanceRemoved is given a tag (a string) and returns a signal which fires under two conditions:
- The tag is removed from an object within the
DataModel
(game) usingCollectionService:RemoveTag
- An object with the given tag is removed as a descendant of the
DataModel
, e.g. by un-settingInstance.Parent
or similar
In the scenario above, none of the conditions were fulfilled. RemoveTag
was not called, and the part’s parent remains the same and it’s not removed within the DataModel game. Is this an expected behavior? To me seems not.