Working with Tags issues

I’m jsut trying to actually get the Tags property. Mostly so I can use that tag to collect later on but I’m having trouble understanding how to even get the property: albeit setting the property.

I have a GoldCoin (1x1x1) part atm and it has a tag on it so I can use the collection service to manage it. Before I can even collect the parts( tagged coins) I need the tags to work properly. The coin/part is cloned and placed into a folder. It has the tag on it after it’s cloned. I can’t get the tagged script to work so I wanted to see if the tag actually exists. I am unable to work out how to print the name of the tag on the coin/part to show it exists.

	--checking coins have a tag
	local taggedCoins = game.Workspace.TaggedParts.TaggedCoins:GetChildren()
	for _, coins in pairs(taggedCoins)do
		if coins:IsA("Part")and coins.Name == "GoldCoin" and coins:HasTag("CoinsTag")then
			print(coins.Name, " exists with a tag of undetermined name")--since Idk how to print the tag
		else
			warn("Somethings not right!")
		end
	end

I don’t know if the tags being cloned are even working. Any ideas?

What about instead of that, clone the instance, and save the instance into a table, then use the table to find the instances instead of looking through the folder?

Actually nvm. I spelled CoinsTag instead of CoinTag, another 3 hours gone ><

1 Like

Still I recommand using arrays instead because why would you loop through false solutions…

congrats on fix thou

Well at least I know the tag is there. Whether or not it works as normal tagged objects remains to be seen.

1 Like

Also while I’m here, any idea how to print the name of a tag?

what do you mean? print(coin.TagName) or like showing it on a GUI or something?

image. i jsut don’t know how to find a tag name.

idk, but maybe

local tags = CollectionService:GetTags(object)

for _, tag in ipairs(tags) do
    print(tag)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.