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

How do I make this COMPLETELY random as well as faster?

Asked by 6 years ago

I want it to make the color spread faster and much more randomly; it seems to jump from one block to the next. (video will be linked shortly)

function onClicked()
    for i, v in pairs (script.Parent.Parent.TronT:GetChildren()) do
        if v:isA("BasePart") and v.BrickColor ~= ("Institutional white") and v.Name ~= ("button") then
            print(v)
            local myArray = {v}
            local target = myArray[math.random(#myArray)]
            print(target, "is being cleansed")
            target.BrickColor = BrickColor.new("Institutional white")
            target.Material = ("Neon")
            wait(0.00000001)
        end

    end
end
 script.Parent.ClickDetector.MouseClick:connect(onClicked)

LINK TO VIDEO ---> https://youtu.be/dt1_2WJJTDc

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I'd try using coroutine (i'm new to it) to make seperate threads. As for the randomness, I'm not exactly sure what you mean. This is the best I could come up with:

function onClicked()
    for i, v in pairs (script.Parent.Parent.TronT:GetChildren()) do
    coroutine.create(function()
        if v:isA("BasePart") and v.BrickColor ~= ("Institutional white") and v.Name ~= ("button") then
            print(v)
            local myArray = {v}
            local target = myArray[math.random(#myArray)]
            print(target, "is being cleansed")
            target.BrickColor = BrickColor.new("Institutional white")
            target.Material = ("Neon")
            wait(0.00000001)
        end
    end)
    end
end
 script.Parent.ClickDetector.MouseClick:connect(onClicked)

Also, I think it looks cool as-is, but have it your way.

Ad

Answer this question