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

Why does this not work in a SurfaceGUI that changes colors of frames?

Asked by 7 years ago

This script does not work.

while true do
local v=script.Parent
wait()
local a=v.R1.BackgroundColor3
a=Color3.random()
wait()
v.R2.BackgroundColor3=a
v.R3.BackgroundColor3=a
v.R4.BackgroundColor3=a
end

1 answer

Log in to vote
2
Answered by 7 years ago

You can't do Color3.Random() instead you can do:

while true do
local v = script.Parent
local num = math.random(0,255)
local num2 = math.random(0,255)
local num3 = math.random(0,255)
wait()
local a = v.R1
a.BackgroundColor3 = Color3.new(num/255,num2/255,num3/255)
 v.R2.BackgroundColor3 = a.BackgroundColor3
v.R3.BackgroundColor3 = a.BackgroundColor3
v.R4.BackgroundColor3 = a.BackgroundColor3
wait()
end
-- You can't do .Random like BrickColor... BrickColor has an index and it select random colors from that. The proper way to do 'random' with Color3 is to use math.random... But remember if you do in fact do that. Use 1 to 0 or #/255 because they do it by a 'percent' thing as to guess. I could give a cleaner example but yeah, good luck! 
Ad

Answer this question