One of them is
1 | for i = 0 , 1 , 0.01 * 100 do |
2 | model:SetPrimaryPartCFrame(CFrame.new( model.Body.Position:Lerp(CFrame.new(- 0.713 , 1045.29 , - 94.712 ).p, i) )* CFrame.Angles(x,math.rad( 0 ),z)) |
3 | wait( 0 ) |
4 | end |
The other is
1 | for i = 0 , 90 do |
2 | model:SetPrimaryPartCFrame(model.Body.CFrame * CFrame.Angles( 0 , 2 * math.rad(i), 0 )) |
3 | wait( 0 ) |
4 | end |
How do I get them to happen at the same time in one script, rather than having one happen before the other?
Use a coroutine:
01 | coroutine.resume(coroutine.create( function () |
02 | for i = 0 , 1 , 0.01 * 100 do |
03 | model:SetPrimaryPartCFrame(CFrame.new( model.Body.Position:Lerp(CFrame.new(- 0.713 , 1045.29 , - 94.712 ).p, i) )* CFrame.Angles(x,math.rad( 0 ),z)) |
04 | wait( 0 ) |
05 | end |
06 | end )) |
07 |
08 | coroutine.resume(coroutine.create( function () |
09 | for i = 0 , 90 do |
10 | model:SetPrimaryPartCFrame(model.Body.CFrame * CFrame.Angles( 0 , 2 * math.rad(i), 0 )) |
11 | wait( 0 ) |
12 | end |
13 | end )) |
use spawn(fn). Spawn is a ROBLOX-specific function that simplifies coroutines for you. It just takes a function and runs it asynchronously.
01 | spawn( function () |
02 | for i = 0 , 1 , 0.01 * 100 do |
03 | model:SetPrimaryPartCFrame(CFrame.new( model.Body.Position:Lerp(CFrame.new(- 0.713 , 1045.29 , - 94.712 ).p, i) )* CFrame.Angles(x,math.rad( 0 ),z)) |
04 | wait( 0 ) |
05 | end |
06 | end ) |
07 |
08 | spawn( function () |
09 | for i = 0 , 90 do |
10 | model:SetPrimaryPartCFrame(model.Body.CFrame * CFrame.Angles( 0 , 2 * math.rad(i), 0 )) |
11 | wait( 0 ) |
12 | end |
13 | end ) |
Check out the Wiki article for more info.