So I am making a egg animation but the egg has 2 parts the top and bottom I want them to tween at the same time when its rotating.
What I tried making a tween for the top and a separate tween for the bottom and played them but it would delay a few seconds.
Can you show us your current script?
local function rotateEgg(pos,rot,Object) -- position rotation object
local info = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
local goal = {
Orientation = rot,
Position = pos
}
local tween = Ts:Create(Object,info,goal):Play()
end
rotateEgg(Vector3.new(49.21, 5.346, 203.087),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Top)
rotateEgg(Vector3.new(48.688, 2.772, 202.592),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Bottom)
coroutine.wrap(rotateEgg)(Vector3.new(49.21, 5.346, 203.087),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Top)
coroutine.wrap(rotateEgg)(Vector3.new(48.688, 2.772, 202.592),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Bottom)
this should fix it (replace your rotateEgg lines with these two.)
Try this
local function rotateEgg(pos,rot,Object) -- position rotation object
coroutine.wrap(function()
local info = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
local goal = {
Orientation = rot,
Position = pos
}
local tween = Ts:Create(Object,info,goal):Play()
end)()
end
rotateEgg(Vector3.new(49.21, 5.346, 203.087),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Top)
rotateEgg(Vector3.new(48.688, 2.772, 202.592),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Bottom)
local function rotateEgg(Position, Rotation, Object)
local Info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local Goals = {Orientation = Rotation, Position = Position}
local Tween = Ts:Create(Object, Info, Goals):Play()
end
task.spawn(function() rotateEgg(Vector3.new(49.21, 5.346, 203.087), Vector3.new(-0.11, -43.7, -15.6), MainFolder.Animation.Egg.Top) end)
task.spawn(function() rotateEgg(Vector3.new(48.688, 2.772, 202.592), Vector3.new(-0.11, -43.7, -15.6), MainFolder.Animation.Egg.Bottom) end)
I don’t know what everyone here is doing with task.spawn and coroutine. There is a delay because the Tween takes time to be created. Just create all the Tweens and then play them at the same time not play the tween right after it’s been made.
local info = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
-- ^ that is outside because it's a constant. There is no need to create it again.
local function rotateEgg(pos,rot,Object) -- position rotation object
local goal = {
Orientation = rot,
Position = pos
}
return Ts:Create(Object,info,goal)
end
local Tween1 = rotateEgg(Vector3.new(49.21, 5.346, 203.087),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Top)
local Tween2 = rotateEgg(Vector3.new(48.688, 2.772, 202.592),Vector3.new(-0.11, -43.7, -15.6),MainFolder.Animation.Egg.Bottom)
Tween1:Play()
Tween2:Play()