So in workspace, If any object is a really red ball I want it to be named "Lock On!". How would I be able to do that?
I tried making the script below but it didn't work! Help!
--This is in a LocalScript
game:GetService('RunService'):Connect(function()
for _, child in pairs(game.workspace:GetChildren()) do
if child.ClassName == 'Part' and child.BrickColor == "Really red" then
child.Name = "Lock on!"
end
end
end)

7 comments
Also, try using child:IsA("Part") instead, and change "Really Red" into BrickColor.new("Really red")
Lastly, and this might be the cause. but you're connecting to RunService directly, not to something like Stepped or RenderStepped.
That is inefficient to just check that every FRAME. Not like you need to check this 60 times a second, 3,600 times a minute. Also, how hard is this for you guys to indent properly?
Also, if you are going to instance a ball (assuming you did not insert it in studio and just like NOT RENAME IT), why cant u just rename the part while making it? Does not make sense.
@himmgoodpack The point of the script is to give names to parts of those properties automatically. Without naming it in Studio.
Why? This makes lag for things that is preventable if YOU JUST NAMED THEM IN STUDIO.