Hello Devs!
I was messing around in Studio the other day and whipped up a quick script to randomly color parts in a game. It’s super simple but can add some fun variety to prototypes, testing environments, or even final projects if you’re going for a chaotic aesthetic. Thought I’d share it here in case anyone finds it useful or wants to expand on it!
The Script
Here’s the code—drop it into a Script
in ServerScriptService or wherever you manage your part modifications:
local function getRandomColor()
return Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255))
end
local function colorParts()
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") then
part.Color = getRandomColor()
end
end
end
-- Run it once on start
colorParts()
-- Optional: Run it every few seconds for a trippy effect
while true do
wait(5) -- Adjust delay as needed
colorParts()
end
How It Works
-
getRandomColor()
generates a randomColor3
value using RGB (0-255 range). -
colorParts()
loops through all descendants inworkspace
, checks if they’reBasePart
objects (like Parts, Wedges, etc.), and applies the random color. - The
while
loop (optional) refreshes the colors every 5 seconds—great for a psychedelic vibe!
Ideas to Expand
- Add a whitelist/blacklist for specific parts or models.
- Tie it to a player command (e.g.,
/randomize
) using aChat
event. - Make it lerp between colors smoothly with
TweenService
.
What do you think? Anyone got cool variations or use cases for this? I’d love to see how others might tweak it—maybe for a party game or a randomizer challenge?
Happy building!
[A1fi_e]