so basically i just need a quik command bar script (the ones u can put at the bottom of studio) to select parts with certain properties. in the script i can somewhere say that the part is x wide and x thick and x color? i know i cant just ask for scripts but its a short command bar one and i cant find it anywhere
the service “Selection” allows you to set what you select
local Selection = game:GetService("Selection")
for i,v in pairs(workspace:GetDescendants()) do
if -- whatever property then
Selection:Set({v})
end
end
This is just a example it can only select 1 part
Use for i impairs loop for it.
For example
for i,v in pairs(workspace:GetDescendants()) do
If v.Something then
end
end
so what do i put after the if? how do i make it select the parts of X height and X color
local Selection = game:GetService("Selection")
for i,v in pairs(workspace:GetDescendants()) do
if v.ClassName == "Part" or v.ClassName == "UnionOperation" then
if v.Color == Color and v.Size.X == Number and v.Size.Y == Number then
Selection:Set({v})
end
end
end
Again this is just a example it can only select one instance at a time. Fill out the color and number.
is the color supossed to be the color code or name
The color should be Color3.fromRGB()
and in those () i put the color code right?
To add on to my code
local Selection = game:GetService("Selection")
local WhatToSelect = {}
for i,v in pairs(workspace:GetDescendants()) do
if v.ClassName == "Part" or v.ClassName == "UnionOperation" then
if v.Color == Color and v.Size.X == Number and v.Size.Y == Number then
table.insert(WhatToSelect , #WhatToSelect + 1, v)
end
end
end
Selection:Set(WhatToSelect)
This could select multiple parts at once.
it didnt quite work as im unsure what to change.ill just say the properties. 33, 84, 185 is the color code, the width is 6.4 and height is 1 of the parts that need to be selected
I’d reccomend you use Instance:IsA(“ClassName”) instead of checking the ClassName property of the Instance.
local Selection = game:GetService(“Selection”)
local WhatToSelect = {}
for i,v in pairs(workspace:GetDescendants()) do
if v.ClassName == “Part” or v.ClassName == “UnionOperation” then
if v.Color = Color3.fromRGB(33, 84, 185) and v.Size.X = 6.4 and v.Size.Y = 1 then
table.insert(WhatToSelect , #WhatToSelect + 1, v)
end
end
end
Selection:Set(WhatToSelect)
this was the finished command she made in DMs but it doesnt work, care to help? (it also has the properties its supossed to select)
I don’t have much experience with Selection service, but have you made sure the parts are put into the table by putting a print next to the table.insert?
Also, I highly reccomend you change the .ClassName checks to part:IsA(“BasePart”)
i have no idea, i cant script. the reason i need the script is because i messed up one of the properties and then copied and pasted a part so many times, its now mixed with other parts so selection group with mouse wont work and doing ctrl click will take way to long so if i use a command to select the parts i can easily change the property
One way of print debugging is to insert prints in the script.
Put a print”Part Found” or whatever text underneath the table.insert line, and if it prints you know that it is selecting those parts. If it prints nothing, then you might of put the wrong properties.
im not that good at scripting, again… maybe instead of selecting the part cant we just change the proprty of the certain parts? like if a part is the color code from the command, 1 stud high and 6.4 studs width, the anchored property becomes anchored NOT UNANCHORED
local Selection = game:GetService(“Selection”)
local whatToSelect = {}
for _, instance in pairs(workspace:GetDescendants()) do
if instance:IsA("BasePart") then --// Check to make sure its a Part
if instance.PROPERTYNAME == VALUE then --// Check any variables you need then
table.insert(whatToSelect, #whatToSelect + 1, instance)
print"Part found, adding to table."
end
end
end
Selection:Set(whatToSelect)
Check the ClassName to determine parts isn’t the best way to check if an instance is a part, IsA() is the preferred method. Whenever you see the text inside of the output, it would mean the part was selected and then selected with Selection:Set(). You will need to change the second conditional statement to add the values you need checked.
Is there anything I need to change to the script itself before putting it in command bar
on the line if instance.PROPERTYNAME == VALUE then
You would need to replace the Property Names you want to check and the value you want to check for there.
Well I’m not a good scripter, how would The sentence be to check the color code listed above and 1 stud height and 6.4 stud width