-
What do you want to achieve? Recolor everything in a folder its like Folder.Model(A few of em)
-
What is the issue? Not sure how to do it.
local folder = -- get the folder
for index, child in ipairs(folder) do
if child:IsA("BasePart") then
child.Color = -- color
end
end
Thanks let me try it! Hope it works
I didn’t try it I just wrote it. I think part.Color might be wrong but you can fix that.
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
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
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 folderPart – part inside of model
Part – part inside of model
Using :GetDesendants() would get everything in the hierarchy.
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
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
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.
Will that work like for everything in a folder even in models and stuff?
Like a Folder.Model.Part
Yes just use @jcnruad900 code. It is simple, just put the color you want inside the quotes.
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)
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
Nvm just accidentaly made an error