When calling CollectionService:GetTagged(), duplicate objects are returned which causes chaos in the game, especially if events get attached to those objects. This happens in both Studio and in a live game. For instance, if there’s four items in the game that have a tag, the API call returns eight items.
Additional Information
Parameter
Value
Problem Area
Engine
Problem Component
API
First Noticed
27 Jan 2025
Priority
High
Impact
Serious
Annoyance Level
Moderate
The beta features that I have enabled are as follows:
Assistant Preview
Texture Generator
As for plugins, I have a bunch that are installed, but very few are enabled. The ones that are enabled are listed below with links to their details page on the Roblox store website:
for _, object in ipairs(collectionService:GetTagged("TabButton")) do
if object:FindFirstAncestorOfClass("PlayerGui") then
print(object.Name)
printToFrame(object.Name)
end
end
GetTagged returns all of things with the tag in the place, regardless of where they are. The buttons with the tag in this case are present in the player’s Gui… and in the starterGui template it was cloned from.
There are two solutions:
Filter the results as described above
Generate the Gui or add the tags at runtime via code
If you use a “binder” pattern for tag handling you can build that filtering code into the binder so that it doesn’t have to be repeated for the various pieces of tag handling code you have.
I do not know why I didn’t see that earlier. But it does make sense now that I think about it. I’ve added a check to see if the GUI is under the player or not, and now it’s working. This can be marked as solved.
It’s not unusual for people to be surprised by this gotcha: When you don’t see the contents in the 3d scene it’s easy to forget that storage like StarterGui / ReplicatedStorage is still part of the main game hierarchy and affected by general APIs.