How would I go about making a rainbow cycling brick?

I’m looking for something like the rainbow pets in pet simulator and I don’t know where to start.


Please read the about page of this category.

Have you tried anything before making this post?


You’ll want to use some kind of loop to do this. While loops are great. Here’s a helpful article to explain loops: and one directly to while loops:

Inside of that loop you’ll want to change the brick color of the brick in question. Here’s the brickcolor api reference:

So bricks have a property BrickColor which you can control with the BrickColor API listed above. If you combine your loop (with some sort of wait in it) you can make the the brick cycle through random brick colors (see random in the BrickColor API reference:

I’m not sure what these rainbow pets do as I’ve never played that game or seen anything from it.

local brick = <TheBrickYouWantToRainbowColor>
while wait(1) do
    brick.BrickColor = BrickColor.random()
1 Like

You can also check out this API to tween between different colors of the rainbow:

I personally think it could be a RGB loop (what the rainbow pets could do, i dont own any rainbow pet in any game)

local Brick = workspace.Brick --Change To Brick
local speed = 1 --Change to speed you want
while true do
	for i = 0,1,0.001*speed do
		Brick.Color = Color3.fromHSV(i,1,1) --creates a color using i

Can you unblur the code, that way we can copy the code :upside_down_face:




Why is it while wait() do instead of while true do? Won’t this make a quick pause every time the colors loop back around?

1 Like

True, im just so used to writing while wait() do to stop it from freezing studio

Also there is no visible difference as it starts and ends in red