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

How do I simultaneously run a for loop?

For example, if I want a brick to levitate and change it's transparency at the same time. I put this.

for i = 1,200 do brick.CFrame = brick.CFrame*CFrame.new(.1,.1,0) wait() end

for transparency = 0,1,.1 do script.Parent.Transparency = transparency wait(.1) end

But what it does is levitate the brick first, and then change it's transparency once it's reached it's final position.

Any help is appreciated.

2 answers

You should just put them both in the same for loop:

for i = 1,200 do 
wait() 
brick.CFrame = script.Parent.CFrame*CFrame.new(.1,.1,0) 
brick.Transparency = script.Parent.Transparency + 0.01
end

If merging for loops doesn't work (as roblox99456789 demonstrates), perhaps because the for loops wait different amounts of time or go on for different total lengths of time, use coroutines:

coroutine.resume(coroutine.create(function()
-- for loop #1 here
end))
-- for loop #2 here.

1 comment

0

can be as effective as a merging

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