How can I get my car to randomize all parts to the same color everytime the server is loaded?
I've created I script which was intended to change the color of a car randomly every time the server was loaded, It worked... sorta. Instead of it changing the parts on a car to a solid color, I got a mixture of the two colors I allowed in my script, Yellow and White. Some of the car is Yellow and some White. I'm assuming it's because It's rolling the random function each time a child with a name "part" is found.
01 | local sportscar 2 color = game.workspace.Cars.Sportscar 2 :GetChildren() |
04 | function PaintCar(part) |
05 | paintRandom = math.random( 1 , 2 ) |
06 | if paintRandom = = 1 then |
07 | part.BrickColor = BrickColor.White() |
08 | elseif paintRandom = = 2 then |
09 | part.BrickColor = BrickColor.Yellow() |
13 | for _, child in ipairs (sportscar 2 color) do |
14 | if child.Name = = "Part" then |
How can I get my car to spawn and change all parts to the same randomly picked color?