How can I make one script's job apply to all the parts in a model instead of having to paste the script in each part seperatly?

when I start the game it’s the metal color but after it reverts back to the original color it’s lighter

local Model = script.Parent
for i,v in pairs(Model:GetChildren()) do
    if v:IsA("BasePart") and v["Name"] == "Step" then
        v.Touched:Connect(function()
        	local OldColor = BrickColor.Gray()  -- Save the color before random
            v.BrickColor = BrickColor.random() 
            wait(5) -- Wait 5 seconds
            v.BrickColor = OldColor
        end)
    end
end
1 Like

I literally cannot thank you enough for your help

1 Like

What if we want to use wait blocks but still have the script run for all parts at the same time?

Any time you create an event, it spawns a new thread so it won’t matter in that scenario

1 Like

When I tried the script, it waited 0.1 seconds for each part when it shouldn’t have