local tweenWhite2 = coroutine.create(function() wf:TweenPosition(UDim2.new(-1,0,0,0)) end) local tweenBlue2 = coroutine.create(function() bf:TweenPosition(UDim2.new(1,0,0,0)) end) local tweenWhite = coroutine.create(function() wf:TweenPosition(UDim2.new(0,0,0,0)) end) local tweenBlue = coroutine.create(function() bf:TweenPosition(UDim2.new(0.5,0,0,0)) end) wait(2) coroutine.resume(tweenBlue) coroutine.resume(tweenWhite) wait(2) for i = 1,0,-0.1 do logo.ImageTransparency = i wait() end wait(5) for i = 0,1,0.1 do logo.ImageTransparency = i wait() end wait(2) coroutine.resume(tweenBlue2) coroutine.resume(tweenWhite2)
It's not exactly clear what you want to happen.
To be clear, coroutines are not concurrent - they run sequentially, not at the same time. However, calling wait()
implicitly yields the thread, giving an "appearance" of true concurrency.
Tweens do not yield the thread. Therefore, there's no need to use coroutines with them at all. In particular, since your coroutines do not yield, and do not do any way of waiting, they could be replaced by ordinary function calls, giving us this:
local function tweenWhite2() wf:TweenPosition(UDim2.new(-1,0,0,0)) end local function tweenBlue2() bf:TweenPosition(UDim2.new(1,0,0,0)) end local function tweenWhite() wf:TweenPosition(UDim2.new(0,0,0,0)) end) local function tweenBlue() bf:TweenPosition(UDim2.new(0.5,0,0,0)) end wait(2) tweenBlue() tweenWhite() wait(2) for i = 1,0,-0.1 do logo.ImageTransparency = i wait() end wait(5) for i = 0,1,0.1 do logo.ImageTransparency = i wait() end wait(2) tweenBlue2() tweenWhite2()
But since you don't actually re-use any of the functions, you might as well just inline them back into the code:
wait(2) bf:TweenPosition(UDim2.new(0.5,0,0,0)) wf:TweenPosition(UDim2.new(0,0,0,0)) wait(2) for i = 1,0,-0.1 do logo.ImageTransparency = i wait() end wait(5) for i = 0,1,0.1 do logo.ImageTransparency = i wait() end wait(2) bf:TweenPosition(UDim2.new(1,0,0,0)) wf:TweenPosition(UDim2.new(-1,0,0,0))
So, again, it's just clear what you want to happen from this. Here's what it should do, as written:
(1) Wait 2 seconds before doing anything
(2) Begin tweening the positions of bf
, and wf
simultaneously.
(3) 2 seconds after tweening starts (which is 1 second after tweening ends), begin to fade inlogo
. This will take about 0.3 seconds.
(4) 5 seconds after the fade in is complete, fade out. This will take about 0.3 seconds again.
(5) Wait 2 seconds after the fade out is complete, then begin to tween both of the objects again.
(6) 1 second after tweening begins, it's complete
If you need further assistance, you need to explain exactly what you want it to do. Because right now it isn't obvious and you haven't described what you want at all.