roblox studio random part color

-- Step 1: Access the workspace in Roblox Studio
local workspace = game:GetService("Workspace")

-- Step 2: Get all parts in the workspace
local parts = workspace:GetChildren()

-- Step 3: Iterate through each part
for _, part in pairs(parts) do
    -- Step 4: Check if the current object is a BasePart (part)
    if part:IsA("BasePart") then
        -- Step 5: Generate a random color
        local randomColor = Color3.new(math.random(), math.random(), math.random())

        -- Step 6: Assign the random color to the part
        part.BrickColor = BrickColor.new(randomColor)
    end
end