Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script won't paint all the parts?

I am attempting to make a gui which when pressed, paints the car sitting on the Detector pad. It works fine just painting normal parts, but when it tries to paint the WedgeParts it brings this error: BrickColor is not a valid member of Weld

here is the code:

--paints the car
-- wow

local detectorpad = script.Parent.Parent.Parent.Parent.Parent.Pad
detectorpad.Touched:Connect(function(part)
		script.Parent.MouseButton1Click:Connect(function()
			if part.Name == "Wheel" then
				local car = part.Parent
				local descendants = car.BodyPanels:GetDescendants()
				for index, descendant in pairs(descendants) do
					 if descendant:IsA("Part") or ("WedgePart") then
						 descendant.BrickColor = BrickColor.new("White")
						print "wee"
					end
					
				end
				
				script.Parent.Parent.Parent.Parent.button:Play()
		end
	end)
end)


1 answer

✓ Accepted answer

alright belive it or not i actually fixed it myself by using two if statements to control the part it paints

local detectorpad = script.Parent.Parent.Parent.Parent.Parent.Pad
detectorpad.Touched:Connect(function(part)
		script.Parent.MouseButton1Click:Connect(function()
			if part.Name == "Wheel" then
				local car = part.Parent
				local descendants = car.BodyPanels:GetDescendants()
				for index, descendant in pairs(descendants) do
					 if descendant:IsA("Part") then
						 descendant.BrickColor = BrickColor.new("Medium stone grey")
						print "wee"
					end
					if descendant:IsA("WedgePart") then
						descendant.BrickColor = BrickColor.new("Medium stone grey")
					end
					
				end
				
				script.Parent.Parent.Parent.Parent.button:Play()
		end
	end)
end)

1 comment

0

you could also do if descendant:IsA("Part") or descendant:IsA("WedgePart") then

This discussion is preserved as it was. New answers, comments, and votes are closed.