What do you want to achieve? I want make object’s position going up to right to down to back to original. Like the square way.
What is the issue? Only one tween working, ignored others.
What solutions have you tried so far? I searched deeply of internet to find how tweens to be in order. Which that why some code seem similar from others.
Here a code, I tried make tweens to be success and in order to make square path.
local remove = script.Parent
local info = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
true)
-
local lift = remove.Position + Vector3.new( 0, 10, 0)
local downPosition = remove.Position + Vector3.new( 0, 0, 0)
local leftPosition = remove.Position + Vector3.new( 0, 0, 10)
local rightPosition = remove.Position + Vector3.new( 10, 0, 0)
local tween1 = TweenService:Create(remove, info, {Position = lift})
local tween2 = TweenService:Create(remove, info, {Position = leftPosition})
local tween3 = TweenService:Create(remove, info, {Position = downPosition})
local tween4 = TweenService:Create(remove, info, {Position = rightPosition})
local function PlayTweens(PT)
for i,k in pairs(PT) do
k:Play()
end
end
PlayTweens({tween1, tween2, tween3, tween4})
A new tween will override a previous tween if the goal affects the same property. Instead, listen for when one tween finishes before playing the next one.
You’re playing all of them at once without waiting for each one to finish. Since playing a new tween on an already tweening instance will cancel out the already playing tween, it skipps all of them except the last one. Try this
for i, k in pairs(PT) do
k:Play()
k.Completed:Wait()
end
this way you’ll wait for the tween to complete before letting the loop continue on to the next tween
Edit: my misstake, forgot tween:Play() doesn’t return anything