local darkLeaves = game.Workspace.Trees.DarkLeaves
while true do
for i , colorPart in ipairs(darkLeaves:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Ghost grey")
end
end
wait(20)
while true do
for i , colorPart in ipairs(darkLeaves:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Parsley green")
end
end
in all while true loops you need to add a task.wait() somewhere
local darkLeaves = game.Workspace.Trees.DarkLeaves
while true do
for i , colorPart in ipairs(darkLeaves:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Ghost grey")
end
task.wait()
end
wait(20)
while true do
for i , colorPart in ipairs(darkLeaves:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Parsley green")
end
task.wait()
end
that didnt work either, this is what I have right now.
local lightGrass = game.Workspace.Terrarin.Lighter
while true do
for i , colorPart in ipairs(lightGrass:GetChildren()) do
colorPart.BrickColor = BrickColor.new("White")
task.wait()
end
end
wait(20)
while true do
task.wait()
for i , colorPart in ipairs(lightGrass:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Sea green")
task.wait()
end
end
local darkLeaves = game.Workspace.Trees.DarkLeaves
task.spawn(function()
while true do
for i , colorPart in ipairs(darkLeaves:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Ghost grey")
end
task.wait()
end
end)
wait(20)
--task.spawn(function()
while true do
for i , colorPart in ipairs(darkLeaves:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Parsley green")
end
task.wait()
end
--end)
--Remove the comments if you're going to have any code down here
While loops yield the code under it and focuses on the code inside of it. But if you make new threads (basically a script in a script) using task.spawn(), the code under can run perfectly fine.
In order to prevent said yielding you can use coroutine.wrap or just combine both loops.
while true do
for i , colorPart in ipairs(lightGrass:GetChildren()) do
colorPart.BrickColor = BrickColor.new("White")
end
task.wait(20)
for i , colorPart in ipairs(lightGrass:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Sea green")
end
-- task.wait(20) ?
end
local lightGrass = game.Workspace.Terrarin.Lighter
for i, colorPart in ipairs(lightGrass:GetChildren()) do
colorPart.BrickColor = BrickColor.new("White")
task.wait()
end
task.wait(20)
for i, colorPart in ipairs(lightGrass:GetChildren()) do
colorPart.BrickColor = BrickColor.new("Sea green")
task.wait()
end