Is there a way so you can make every part in a group be New yeller at the same time without using for i,v in pairs?
--I do this, if you have any tips or anything you want to point out to me that could make this be easier and better. while true do wait() for i,v in pairs(script.Parent:GetChildren()) do if v ~= script then if v:IsA("BasePart") then v.BrickColor = BrickColor.new("New Yeller") end end end end
local p = script.Parent; local bcl = BrickColor.new("New Yeller") while wait() do local c = p:GetChildren(); for i=1,#c do if c[i]:IsA"BasePart" then c[i].BrickColor = bcl; end; end; end;
Unless script.Parent is going to change a lot, cache it. Unless the BrickColor is going to change a lot, cache it. Pairs runs in about 3x as much time as a standard for loop. You don't need to check if it's not the script if you're also checking if it is a BasePart.
No, it cannot be faster unless you're looking for a certain name:
Local find = game.Workspace: FindFirstChild("ColorPart",true) If find then --code End
FindFirstChild has two parameters: 1. what you want to find 2. search through all descendants (default at false )