Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Set part to random colour is not working?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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())
0
Thank you. Blxefirx 31 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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...

Answer this question