How to recolor everything in a folder

  1. What do you want to achieve? Recolor everything in a folder its like Folder.Model(A few of em)

  2. What is the issue? Not sure how to do it.

2 Likes
local folder = -- get the folder
for index, child in ipairs(folder) do
    if child:IsA("BasePart") then
        child.Color = -- color
    end
end
2 Likes

Thanks let me try it! Hope it works

2 Likes

I didn’t try it I just wrote it. I think part.Color might be wrong but you can fix that.

1 Like
for i, child in ipairs(folder:GetDescendants()) do
    if child:IsA("BasePart") then
        child.Color3 = Color3.fromRGB(255,255,255) -- change to whatever you want
    end
end

Fixed from @SnarlyZoo’s reply

3 Likes

If the folder can have other folders/models, you can do something like this:

local function recolorFolder(folder, color3)
	for _, item in pairs(folder:GetChildren()) do
		if item:IsA("Part") then
			item.Color = color3
		elseif item:IsA("Model") or item:IsA("Folder") then
			recolorFolder(item, color3)
		end
	end
end

recolorFolder(workspace, Color3.fromRGB(255, 255, 255)) -- recolor everything in the workspace
1 Like

I think using folder:GetDescendants() would do better since it gets all of the items. For example:

Folder – main folder

Model – model inside of folder

Part – part inside of model
Part – part inside of model
Wedge – part inside of model
Folder – folder inside of folder
Model – model inside of folder

Part – part inside of model
Part – part inside of model

Using :GetDesendants() would get everything in the hierarchy.

2 Likes

Ill try this than but would you just look for the name and if its called part than change the color?

Any way you can check the name and not check if its a part so i could color kill parts diffrently

1 Like

Like has to be a part and called Part to get one color and than a darker one for something called KillPart

for i, child in ipairs(folder:GetDescendants()) do
    if child:IsA("BasePart") then
        if child.Name == "Part" then
            child.Color3 = -- get color
        elseif child.Name == "KillPart" then
            child.Color3 -- get color
        end
    end
end
1 Like

The property for a BasePart’s color is not called “Color3”, but rather “Color”.

 for i, v in pairs(folder:GetDescendants()) do
    if v:IsA("BasePart") then
        if v.Name == "Part" then
            v.BrickColor = BrickColor.new("") --Put color between the quotes
        elseif v.Name == "KillPart" then
            v.BrickColor = BrickColor.new("") --Put color between the quotes
        end
    end
end

It will recolor everything in folder and in every model inside it.

1 Like

Will that work like for everything in a folder even in models and stuff?
Like a Folder.Model.Part

2 Likes

Yes just use @jcnruad900 code. It is simple, just put the color you want inside the quotes.

1 Like

Alright well im gonna change the BrickColor.new() to a color value

If you want an RGB color then you can do:

child.Color = Color3.fromRGB(0, 0, 0)
1 Like

Works perfectly thanks. Im gonna mark your comment as solution!

Wait no it doesnt work on the kill parts it lets them the same color as normal parts

1 Like

Nvm just accidentaly made an error :smiley: