Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i make the background of my gui change colour for a player with a math.random script?

Hello, so i want to make it so for every player a different background colour appears for the loading gui so i put this in a local script:

script.Parent.BackgroundColor3 = Color3.new(math.random(1,255),math.random(1,255),math.random(1,255))

all this does is making it white all the time?

1 answer

✓ Accepted answer

What your doing is correct, but the reason it is making it white is because you are not dividing the individual numbers by 255 to return rgb.

script.Parent.BackgroundColor3 = Color3.new(math.random(1,255)/255,math.random(1,255)/255,math.random(1,255)/255)

Notice how I divided the numbers returned by math.random by 255

Alternatively you could use Color3.fromRGB() to not have to divide the numbers.

script.Parent.BackgroundColor3 = Color3.fromRGB(math.random(1,255),math.random(1,255),math.random(1,255))

1 comment

0

Thanks, but scripting guider or something already helped me! thanks for reacting!

This discussion is preserved as it was. New answers, comments, and votes are closed.