Matching a Tag with A model name

Hi all, ive been trying to find a way to make it when a button is clicked it scrolls through allthe decendents of the character and when it finds an accessory with a certain tag name that matches the same name of a model in workspace it sets the model to Transparency = 1.

Dont have much else to say as not really sure how to get round it. No experience with Tags before so help would be appreciated!!

1 Like

This is how you could iterate over all accessories and check if it has a specific tag, setting the transparency to 1 if it does.

local CS = game:GetService("CollectionService")

buttonInstance.MouseButton1Click:Connect(function()
	local targetName = "WorkspaceObjectName"
	for _,v in pairs(char.Humanoid:GetAccessories()) do
		if CS:HasTag(v, targetName) then
			for _, p in pairs(v:GetDescendants()) do
				if p:IsA("BasePart") then
					p.Transparency = 1
				end
			end
		end
	end
end)

1 Like

Hi thanks for the reply i edited it to try get it to work with my button and still no luck. Am i doing something wrong?

1 Like

replace Humanoid:GetChildren() with Humanoid:GetAccessories()

1 Like