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

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

Asked by 6 years ago

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

Log in to vote
1
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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))
0
Thanks, but scripting guider or something already helped me! thanks for reacting! DanielDeJong3 158 — 6y
Ad

Answer this question