i wanna know if you can randomized mixed numbers with math.random.
im working a random part color thingy, and wanna have more colors than just primary ones mixed
but the color3.new thingy only allows 0 - 1 in mixed numbers to change color, not 0 - 255
Use Color3.fromRgb, or just generate your RGB values in [0; 1] and use Color3.new that works just as well.
if you want to use numbers up to 255, you use Color3.fromRGB()
instead of Color3.new()
.
otherwise, you use math.random()
without any arguments, which will give you a decimal between 0 and 1.
or:
math.random(255)/255
that works good mans, thanks!
char limit
I don’t think it’s possible to use math.random()
for directly outputting mixed numbers without using extra operations (*because it only returns Integers), but you could use Random:NextNumber()
to generate non-integers on a 0-1 scale by setting its minimum to 0 and maximum to 1.
Example
local randomSeed = Random.new()
local randomTest = randomSeed:NextNumber(0, 1)
-- Generates a decimal number between 0 and 1
print(randomTest)
Edit: Although if you still wanted to use math.random()
, then the solutions offered by the other users should work for the use case you described.
Or, what @Forummer just mentioned if you want it to strictly use the preset BrickColor Codes.
Part.BrickColor = BrickColor.Random()
You could just use the built-in random ‘BrickColor’ constructor function.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.