How do I get all parts in workspace that are a certain color?

I’m trying to recolor a vehicle that has a lot of parts and I only want to color certain parts, is there any way to only get the grey parts of the helicopter using a script in the command bar or something? It would be extremely helpful, also, I’m not sure if this is building or scripting but I’ll post it here for now I guess.

Thanks,
– Luke

1 Like
for _, Part in pairs(workspace:GetDescendants()) do
    if Part:IsA("Part") then
        if Part.Color == Color3.new(255, 255, 255) then
            Part.Color = Color3.new(255, 0, 255)
        end
    end
end
2 Likes
for index, part in pairs(workspace:GetDescendants()) do
	if part.Color == Color3.new(0,0,0) then -- Your color here
		--code here
	end
end
1 Like

I ran that in the command bar but it wouldn’t change the color…

for _, Part in pairs(workspace:GetDescendants()) do
    if Part:IsA("Part") then
        if Part.Color == Color3.new(163, 162, 165) then
            Part.Color = Color3.new(48, 63, 25)
        end
    end
end

try this

for index, part in pairs(workspace:GetChildren()) do
	if part.Color == Color3.new(0,0,0) then -- Your color here
		--code here
	end
end

My bad, use Color3.fromrgb, that’s for parts.

for _, Part in pairs(workspace:GetDescendants()) do
    if Part:IsA("Part") then
        if Part.Color == Color3.fromRGB(255, 255, 255) then
        Part.Color = Color3.fromRGB(255, 0, 255)
        end
    end
end

yeah that counts too
(character limit)

No, also you should detect if Instance is a part.

So uh, there are unions and meshes inside of the model just saying…

Include the unions.

for _, Part in pairs(workspace.Helicopter:GetDescendants()) do
    if Part:IsA("Part") or Part:IsA("UnionOperation") then
        if Part.Color == Color3.fromRGB(255, 255, 255) then
        Part.Color = Color3.fromRGB(255, 0, 255)
        end
    end
end
1 Like

There’s models of characters inside the game as well. What if I get the descendants of the model rather than the workspace?

Put the helicopter in a folder, and try again with the updated script.

image

image

That single error stops the entire script, make sure the Union has UsePartColor set to true, and use the script again, i’d update it 20 mins ago.