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

How to put random color on a car's paint blocks?

Asked by 3 years ago

I am currently making a game where you can drive around with cars and I am making a tuning garage where you can change the color of your car. How the tuning garage works is it comes up with a random color and puts that color on your car's paint parts. The first script

bin = script.Parent

function onTouched(part)
    if part.Name == "Paint" or  part.Name == "PaintB" then
            part.BrickColor = script.Parent.BrickColor
    wait(.3)
    end
end

The second script

while true do
script.Parent.Color = Color3.new(math.random(), math.random(), math.random())
wait(5)
end

1 answer

Log in to vote
1
Answered by
DesertusX 435 Moderation Voter
3 years ago

Hello!

I see your problem here. In the second script, you aren't setting the m and n values of the math.random. These are the values that set the minimum and maximum of the random numbers. For example, if you wanted to be given a random number between 1 to 100, you would type something like this: print(math.random(1 --The minimum, 100 --The maximum). Or ,if you wish your minimum number to be one, you can just totally remove the minimum number, and it would look something like this: print(math.random(100 --The maximum). It would still work flawlessly.


In your case, the numbers you should probably use are 0 and 1, since with Color3 the values are from 0 to 1. You also have to use the minimum number (0), because it is not 1. However, if you wish to have a wider option colours; you should probably use Color3.fromRGB. Instead of the colour values arranging from 0 to 1, your options would be from 0 to 255. To use this option, replace Color3.new from the second script to Color3.fromRGB. Obviously, here, you should make the minimum number 0 and the maximum number 255.

I hope this helps!

THANKS FOR READING!

Ad

Answer this question