Attempt to index nil with Background color when the the thing does exist?

So I have a script that should change the background color of a Text Button but it always says that the button does exist.

I print the button before hand and yes it is there. So why is this happening?

local function refresh()
	for _, item:Folder in pairs(items:GetChildren()) do
		if item:IsA('Folder')  then
			local tag = script:FindFirstChild('Tag'):Clone()
			tag:FindFirstChild('Name').Text = item.Name
			print(tag:FindFirstChild('Equip'))
			if item:FindFirstChild('Owned')  then
				if items:FindFirstChild('Equipped').Value == item then
					tag:FindFirstChild('Equip').Name = 'EQUIPPED'
					tag:FindFirstChild('Equip').BackgroundColor3 = Color3.fromRGB(147, 147, 147) -- errors here/ set color
				else
					tag:FindFirstChild('Equip').Name = 'EQUIP'
					tag:FindFirstChild('Equip').BackgroundColor3 = Color3.fromRGB(0, 170, 255) -- set color
				end
			else
				tag:FindFirstChild('Equip').Name = 'BUY'
				tag:FindFirstChild('Equip').BackgroundColor3 = Color3.fromRGB(0, 255, 127) -- set color
			end
			
			tag:FindFirstChild('Equip').Activated:Connect(function()
				event:FireServer(item)
			end)
			
			tag.Parent = frame:FindFirstChild('ScrollingFrame')
			tag.Name = item.Name
			
			print('Tag created')
		end
	end
end

Try putting it on-top of the “tag:FindFirstChild(‘Equip’).Name = ‘EQUIPPED’”

1 Like

I see now that I was setting the name instead of the text! Thank you so much

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