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

Why do these change color at the same time even though I have a wait?

local s1 = script.Parent.Spawn1
local s2 = script.Parent.Spawns2:GetChildren()

local loop = coroutine.create(function()
	while true do
		wait(.4)
		s1.BrickColor = BrickColor.Random()
	end
end)
coroutine.resume(loop)
wait(.4)
local loop2 = coroutine.create(function()
	while true do
		wait(.4)
		for i,v in pairs(s2) do
			v.BrickColor = s1.BrickColor
		end
	end
end)
coroutine.resume(loop2)

The second set of spawns are meant to wait .4 seconds before they change but they change right when the first spawn changes. Why?

1 answer

local loop2 = coroutine.create(function()
    while true do
        for i,v in pairs(s2) do
		wait(0.4)
            v.BrickColor = s1.BrickColor
        end
	wait() -- make sure that the loop doesn't crash the script
    end
end)

1 comment

0

That changes one of the two spawns at a different time than the other spawn.

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