Color changer script help

this does not change the brickcolor any help?

if  value >= 1000 then

sphere.BrickColor = BrickColor.new (math.random (), math.random (), math.random () )

else

...

try BrickColor.random()
BrickColor | Documentation - Hub Création Roblox

do i just delete all the math.random then?

Here is a working script that changes colors randomly.

if  value >= 1000 then
local rand = math.random(0,255)
sphere.Color = Color3.fromRGB(rand, rand, rand)

else

...
2 Likes

Hi,

if  value >= 1000 then

sphere.Color= Color3.fromRGB(math.random (0,255), math.random (0,255), math.random (0,255) )

else

BrickColor is a text-based value that is assigned to a range of Color3s, while Color and Color3.fromRGB can take 3 numbers ranging from 0-255. This should fix your code.

Doesn’t it range from 0 - 255? Because 0, 0, 0 is the lowest it can go, giving you the darkest black.

1 Like

Correct, I don’t use fromRGB anymore as Color3.new() gives a much larger range of shades but thank you for fixing my mistake regardless.

1 Like

thanks , whats even the difference when u change the brick color and the color property coz they both look the same visually on the part i guess?

BrickColor.new() only takes strings that are predefined, for example BrickColor.new(“New yeller”)

It has been kept in favor of older games and allowing newer players to choose colors easily.

Color3.fromRGB() takes 3 numbers ranging from 0 to 255 to define an RGB color e.g. Color3.fromRGB(255,255,255) is White

The difference is that BrickColor takes predefined strings that Roblox has set, and Color3.fromRGB takes a random sequence of numbers which allows for thousands of possible colors.

1 Like

oh wow i never knew that, i thought they’re different things thank you for explaining it also in ur script is there anyway to remove the yellow colors from it? as i dont want any yellow shades on my part

use BrickColor.random()

even though @fouroul94 already mentioned it and @oSudden already solved this, im still gonna say it

if  value >= 1000 then

sphere.BrickColor = BrickColor.random()

else

...

there, just as easy as that! have a nice day!

1 Like

instead of .random how do i make it go through 5 colors of my choice

Store those colors in a table and then pick a random value in the table like this
Local color = Table[math.random(1,#Table)]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.