Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

So when i do a brickcolor=brickcolor.random it always gives me the same colors?

Asked by 8 days ago
local fonzi = coroutine.create(function()
    while true do
    luis.BrickColor=BrickColor.Random()
    wait(.5)    
    end 
end)
coroutine.resume(fonzi)

so whenever i run this, it will return a random color for the brick PS luis is an instanced in part, but it will always just give me different shades of the same rgb such as red or green or blue, and doesn't differentiate, plz help <3

1 answer

Log in to vote
0
Answered by
Sparks 484 Moderation Voter
7 days ago

.Random() is likely running on the same pattern because it has not been reseeded. You can try this method for a truly "random" color.

local fonzi = coroutine.create(function()
    math.randomseed(tick()) --Randomize the server's seed (change the pattern of math.random()) 

    while true do
        local randcolor = Color3.fromRGB(math.random(0,255), math.random(0,255), math.random(0,255)) --Randomize three RGB values

        luis.BrickColor=BrickColor.new(randcolor) 
        wait(.5)    
    end 
end)
coroutine.resume(fonzi)
Ad

Answer this question