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

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

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

✓ Accepted answer

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.

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