Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Set part to random colour is not working?

Hello there. I wanted to make the baseplate turn to a random colour, and it's not working.

This is the code I tried:

local Baseplate = game.Workspace.Baseplate


while true do
	Baseplate.Color = Random
end

This is a script inside of workspace.

Please can someone help? Thanks, Blxefirx.

I don't know why I want a rainbow baseplate.

2 answers

✓ Accepted answer

A couple things.

1 - having a while true loop without any waits will crash your program. Stick a wait(0.5) in there (or however long you want the interval to be between changing colours).

2 - Random is undefined. There are 2 ways you could set a random colour:

The first is to use the in-build BrickColor.random() function on the baseplate's BrickColor property:

BasePlate.BrickColor = BrickColor.random()

And the second (for a bit more range) is to use math.random() to generate a random number between 0 and 1 to fill in the Color3.new() constructor:

BasePlate.Color = Color3.new(math.random(), math.random(), math.random())

1 comment

0

Thank you.

You could just say this:

while true do
	game.Workspace.Baseplate.BrickColor = BrickColor.new(Random)
	wait(0.5)
end

If It doesn't work, Then try using what I typed but you type it...

This discussion is preserved as it was. New answers, comments, and votes are closed.