Adding tags in server destroys client side tags (Collection Services)

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) using CollectionService:RemoveTag
  • An object with the given tag is removed as a descendant of the DataModel , e.g. by un-setting Instance.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.

https://developer.roblox.com/en-us/api-reference/class/CollectionService

This is expected behavior, if you need something that doesn’t get overwritten use Attributes, ValueBase or store data in a table

1 Like