I have tried to do:
while true do
game.workspace.part.Color = game.workspace.part.Color.Random()
wait(100)
end
But it never changes color, can someone tell me why? I have only been coding in Lua for a couple months on the dev wiki.
Okay, so first of all “color” is not what you want. You want BrickColor.
Color has 3 numbers so if you wanted you could do
01 | function random() |
02 | num 1 = math.Random( 1 , 255 ) |
03 | num 2 = math.Random( 1 , 255 ) |
04 | num 3 = math.Random( 1 , 255 ) |
05 | end |
06 |
07 | while true do |
08 | random() -- this calls the function |
09 | game.Workspace.Part.Color = Color 3. new(num 1 , num 2 , num 3 ) |
10 | wait( 100 ) |
11 | end |
Of course the way simpler way to do it with less colors is
1 | while true do |
2 | |
3 | game.Workspace.Part.BrickColor = BrickColor.Random() |
4 | wait( 100 ) |
5 | |
6 | end |
Hope this helps!!
You need to change it to brickcolor, you can’t just say color. Also it’s going to change every 100 seconds, since you said wait(100)
Here what I came up with.
while true do game.workspace.part.BrickColor = BrickColor.Random() wait(1) end
Change the wait to whatever you prefer.