I Am Tyring to make a parkour map that the colors of some blocks that change, but i am also using to "while true do" things, and it only chooses one to do? Please help, im new to scripting and am eager to learn!!! <MY SCRIPT: please ask if u need more details!
local Part1 = game.Workspace.FancyJumpParts.Part1 local Block1 = game.Workspace.JumpBlocks.Block1
while true do Block1.BrickColor = BrickColor.Green() wait(3) Block1.BrickColor = BrickColor.Yellow() wait(3) Block1.BrickColor = BrickColor.Black() wait(3) Block1.BrickColor = BrickColor.Random() wait(3) end
while true do Part1.BrickColor = BrickColor.Red() Part1.CanCollide = false wait(5) Part1.BrickColor = BrickColor.Blue() Part1.CanCollide = true wait(5)
end
With using a code block, your code looks like this,
local Part1 = game.Workspace.FancyJumpParts.Part1 local Block1 = game.Workspace.JumpBlocks.Block1 while true do Block1.BrickColor = BrickColor.Green() wait(3) Block1.BrickColor = BrickColor.Yellow() wait(3) Block1.BrickColor = BrickColor.Black() wait(3) Block1.BrickColor = BrickColor.Random() wait(3) end while true do Part1.BrickColor = BrickColor.Red() Part1.CanCollide = false wait(5) Part1.BrickColor = BrickColor.Blue() Part1.CanCollide = true wait(5) end
Lua can only do one thing at a time, and it reads from top to bottom, mainly. Once the code reaches the first loop, it never sees the other one. It never breaks out.
There are multiple ways of fixing this, but since you want specific timings, I would suggest the simplest solution by using the spawn function.
This will allow your code to see both loops and deal with them accordingly.
local Part1 = game.Workspace.FancyJumpParts.Part1 local Block1 = game.Workspace.JumpBlocks.Block1 spawn(function() while true do Block1.BrickColor = BrickColor.Green() wait(3) Block1.BrickColor = BrickColor.Yellow() wait(3) Block1.BrickColor = BrickColor.Black() wait(3) Block1.BrickColor = BrickColor.Random() wait(3) end end) while true do Part1.BrickColor = BrickColor.Red() Part1.CanCollide = false wait(5) Part1.BrickColor = BrickColor.Blue() Part1.CanCollide = true wait(5) end
Good Luck!