Equipping Tool w/ CollectionService tag removes the tag on clients other than the first to connect to game

This bug has been fixed by Roblox

When I equip a tool with a CollectionService tag on it and I am not the first client to connect to the game, the CollectionService tag gets removed

Below are GIFs of the issue (look at the output window and when I equip the tool). The GIFs are from test servers inside of studio but I am pretty sure this happens in live servers as well from my testing

I have the following in the place file in the GIFs:
A Tool in StarterPack
A LocalScript in StarterCharacterScripts with the following code:

local collectionService = game:GetService("CollectionService")

local player = game.Players.LocalPlayer
local character = player.Character

local backpack = player.Backpack
local tool = backpack.Tool

collectionService:AddTag(tool, "test")

tool.AncestryChanged:Connect(function(_, newParent)
	print(newParent, collectionService:HasTag(tool, "test"))
	wait()
	warn(newParent, collectionService:HasTag(tool, "test"))
end)

Player 1 (works as expected; tag stays on Tool when equipped)
https://gyazo.com/f77e342174c8489b16eb95b8d8c61fcf

Player 2 (does not work as expected; tag gets removed from Tool when equipped)
https://gyazo.com/b2b629256701465f8cccea6c7fed11a5

Player 3 (does not work as expected; tag gets removed from Tool when equipped)
https://gyazo.com/f28c10662929ba83243e533a5462f0c0

Here is the file that is being used in the GIFs: collection-service-bug.rbxl (21.6 KB)

Is this a bug or an issue on my end? I haven’t seen anyone else saying they have this problem

If you’re adding the tag from the client, and it looks like you are, the other clients will have no way of knowing the tool has a tag because of Roblox’s replication rules.

I am adding the tag to each client’s tool on the respective client because the LocalScript with the code is in StarterCharacterScripts

I understand why you had this misconception because the title’s wording is a little confusing

1 Like

Out of curiosity I added a listener for CollectionService:GetInstanceRemovedSignal() to see if it was getting removed and it was.

Don’t know if this is the source of your problem but according to the documentation for GetInstanceRemovedSignal there are 2 conditions where the event is fired:

  • The tag is removed from an object within the DataModel (game) using CollectionService:RemoveTag (not the case for your scenario)

  • An object with the given tag is removed as a descendant of the DataModel , e.g. by un-setting Instance.Parent or similar

Not really to sure if this solution is suitable for your use case, apologies if it isn’t:

local collectionService = game:GetService("CollectionService")

local player = game.Players.LocalPlayer
local character = player.Character

local backpack = player.Backpack
local tool = backpack.Tool

collectionService:AddTag(tool, "test")

tool.AncestryChanged:Connect(function(_, newParent)
	if tool.Parent.Name == "Backpack" and not collectionService:HasTag(tool, "test") then
		collectionService:AddTag(tool, "test")
	end
	print(newParent, collectionService:HasTag(tool, "test"))
	wait()
	warn(newParent, collectionService:HasTag(tool, "test"))
end)

I wanna ask is it possible to check a tag on the server instead of a client?

Thank you for the detailed explanation. I’m guessing this is a bug on Roblox’s end since both conditions are not met when the tag is being removed…

I will not mark your post as a solution because your solution is not very practical for me, but your reply was helpful because now I know it is probably not an issue only for me

1 Like

Are you asking if you can use CollectionService:HasTag on the server? If you are, then the answer is yes, as long as the tag is applied on the server

2 Likes

When tags replicate, all tags on an object replicate at the same time . Therefore, if you set a tag on an object from the client then add/remove a different tag on the same object from the server, the client’s local tags on the object are overwritten.

Could this be part of the problem?

Edit: it’s probably not this then.

I am not using CollectionService anywhere on the server, so unless I am misunderstanding what the quote is saying, I don’t think so

1 Like