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

Random Rgb color doesn't change ?

Hi i tried to make a "rgb" generator

local R = math.random(0,255)
local G = math.random(0,255)
local B = math.random(0,255)

while wait(0.5) do
	print(R,G,B)
end

It works fine but it doesn't generate randomly.

Output :

138 147 6
ContentProvider:PreloadAsync() failed for rbxassetid://99666917
138 147 6 (6x)

I always get the same result but if i stop and i play again it change

(Hope you understand and sorry for my english)

1 answer

✓ Accepted answer

You’re only generating the random numbers once, that’s why.

Put the values in the loop so it will randomly generate the numbers constantly. You don’t even need to set up variables for it actually.

Here’s how I would do it :

while wait(.5) do
    print(math.random(255), math.random(255), math.random(255))
end

but if you want the variables, here’s how you would put it :

while wait(.5) do
    local R = math.random(0, 255)
    local G = math.random(0, 255)
    local B = math.random(0, 255)
    print(R, G, B)
end

Hope this helped!

1 comment

0

Thanks !

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