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)
This script should work for you. You need to use IsA
instead of using ClassName
and using RunService will spam Lock On.
for i,c in pairs(game.Workspace:GetChildren()) do if c:IsA("Part") then --Use "IsA" instead if c.BrickColor == "Really red" then print("Lock On") end end end
I'm on mobile so I apologize for poor indentation. Please accept my answer if this helped!