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

Adding colors to BrickColor.new()?

Asked by 5 years ago
for i, v in pairs(children) do
    while blocks >= 1 do
    block = children[math.random(1,30)]
    block.BrickColor = BrickColor.new(0 + math.random(10,20),0,0)
    wait(0.5)
    end
end

I want to actually make it so each time this code randomly selects a block it becomes more red, as in it adds more red to the previous BrickColor value. Is this possible?

0
I'll fix it hold on Z0ggg 20 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

You can lerp the block's color with a for i = 1, 2 do loop.

--color1 will be the starting color, color2 finish color
local Color1, Color2 = BrickColor.new("Bright red").Color, BrickColor.new("Really red").Color

function LERP()
    for i = 0, .35, .01 do 
        block.Color = block.Color:lerp(Color1, i)
        wait()
    end

    for i = 0, .35, .01 do 
        block.Color = block.Color:lerp(Color2, i)
        wait()
    end
    LERP() --loops the function
end

LERP()
Ad
Log in to vote
0
Answered by 5 years ago

0 + math.random(10,20),0,0 will give you (10 to 20,0,0) every time, not slowly increase it.

If you want to increase each loop, I suggest using the Color property, and slowly adding to the r property of Color3

red = block.Color.r
block.Color = Color3.fromRGB(red + math.random(10,20),0,0)

Answer this question