Attempt to index number with 'Name'

local Coat = script.Parent.Parent
	
script.Parent.MouseClick:Connect(function()
	for texture in pairs(Coat:GetDescendants()) do
		if texture.Name == "MTP" then
			if Coat.Transparency == 0 then
				Coat.Transparency = 1
				texture.Transparency = 1
			else
				if Coat.Transparency == 1 then
					Coat.Transparency = 0
					texture.Transparency = 0
				end
			end
		end
	end
end)
  16:42:28.173  Workspace.CoatProp.ClickDetector.Script:5: attempt to index number with 'Name'  -  Server - Script:5

Iā€™m not familiar with the error nor familiar with how to fix it

Change this

for texture in pairs(Coat:GetDescendants()) do

To this

for _,texture in pairs(Coat:GetDescendants()) do

First thing is the index, 2nd thing is the thing in that table, you need to use the 2nd thing

1 Like

Use for _,texture

You forgot to make 2 parameters