Command Bar? I don’t believe you can, that can only accept 1 line of code
However you can do this via a script using GetDescendants() I believe:
local Trees = workspace.Kingdom.Detail.Trees["Oak Trees"]:GetDescendants()
local ColorToChange = BrickColor.new("Shredded Potato") --This is just an example, change this to whatever you want lol
for _, Leaves in pairs(Trees) do
if Leaves:IsA("BasePart") then
Leaves.BrickColor = BrickToChange
end
end
Actually you can use multiple lines of code in the command bar, it just condenses it into a line when pasting into it, but if you copy back the line and paste it, it’ll keep the formatting I believe
Well if you want to select the parts, which I’m assuming that you do, there’s a nice example on how to use Selection (service)
In your case I would throw this in the command bar
local Selection = game:GetService("Selection")
local newSelection = {}
for _, object in pairs(workspace:GetDescendants()) do
if object.Name == "Leaves" then
table.insert(newSelection, object)
end
end
Selection:Set(newSelection)
Paste this script I made into the command bar. Set the name variable to the name of the things you want to select.
local objects = {}
local lookForName = "Baseplate" -- Name of things you want to select.
for i,v in pairs(workspace:GetDescendants()) do
pcall(function()
if v.Name == lookForName or lookForName == "all" then
table.insert(objects,v)
end
end)
end
game:GetService("Selection"):Add(objects)
local Trees = workspace.Kingdom.Detail.Trees["Oak Trees"]:GetDescendants()
local ColorToChange = BrickColor.new("Neon orange")
for _, Leaves in pairs(Trees) do
if Leaves:IsA("BasePart") then
Leaves.BrickColor = ColorToChange
end
end
Hi, seeing as how others have given the code to solve this issue I just want to recommend this paid plugin that might make doing stuff like this a little easier: InCommand by Elttob & boatbomber. For whatever reason I didn’t like using the regular command line in Studio and found this plugin very useful. It’s helped me work with large groups of models all at once and do things similar to what you’re doing here. I like it because it keeps the formatting in your scritps and it can also save your scripts. I’m also not super into Roblox scripting yet but I found faster and easier to practice with this plugin. It is not free, however.
You can read more about this plugin in this post. Keep in mind that this plugin isn’t necessary, but you may want to consider it. If you decide to use this plugin I hope it helps!
for _, selected in pairs(Location:GetChildren()) do --[[Do what you want here, remove the brackets and the --. selected is all the selected parts.]] end
I mean assuming that their parent’s name is oak, you can do a check like this
if object.Parent.Name == "Oak" then
Modified code
local Selection = game:GetService("Selection")
local partName = "Leaves"
local parentName = "Oak"
local newSelection = {}
for _, object in pairs(workspace:GetDescendants()) do
if object.Name == partName and object.Parent.Name == parentName then
table.insert(newSelection, object)
end
end
Selection:Set(newSelection)