I have a large number of parts that I want to turn blue when touched. Unfortunately, I need to insert the same script into every single part, which is very tedious.
Here is the script:
script.parent.Touched:connect(function(plr) script.parent.BrickColor = BrickColor.Blue() end)
Is there any way I can cycle through all the parts and run this script instead of having to insert it into every single part?
You'll want to use a generic for loop and you'll also want to parent all your touchables to one thing, whether it's a model or a folder it doesn't really matter, but it'll look like this:
for _, Child in ipairs(CommonParent:GetChildren()) do Child.Touched:Connect(function(ActedPart) Child.BrickColor = BrickColor.Blue() end) end