Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make this part tween to the right positions?

Asked by 5 years ago

I am making a sequence where a part comes flying of after launching and it should tween to one position and then another 4 times (in different positions.) When I go to test this. Nothing happens, until the last tween which plays. I want the middle tweens to play as well.

The script is here:

local TweenService = game:GetService("TweenService")
local part = game.Workspace.Fakeship
local part2 = script.Parent.Parent.Parent.Parent.Parent.knockout
script.Parent.MouseButton1Click:Connect(function()
    if script.Parent.alreadylauched.Value == false then
        script.Parent.alreadylauched.Value = true
    wait(4)

 local tweenInfo = TweenInfo.new(
     5, -- Length
     Enum.EasingStyle.Linear, -- Easing Style
     Enum.EasingDirection.Out, -- Easing Direction
     0, -- Number of times the tween will repeat
     false, -- Repeat?
     2 -- Delay Between each tween
)

local goal = {
CFrame = CFrame.new(-3623.92871, 1653.40479, 513.185974)* CFrame.Angles(0,math.rad(0), 0)
}

local tween = TweenService:Create(part, tweenInfo, goal)

tween:Play()

    wait(3)
    local explos = Instance.new("Explosion")
    explos.ExplosionType = ("NoCraters") 
    explos.Parent = game.Workspace.explosionpos
    explos.Position = game.Workspace.explosionpos.Position
end
wait(2)
 local tweenInfo2 = TweenInfo.new(
     0.6, -- Length
     Enum.EasingStyle.Linear, -- Easing Style
     Enum.EasingDirection.Out, -- Easing Direction
     0, -- Number of times the tween will repeat
     false, -- Repeat?
     2 -- Delay Between each tween
)

local goal2 = {
CFrame = CFrame.new(-3623.19189, 1558.49438, 510.58075)
}

local tween2 = TweenService:Create(part2, tweenInfo2, goal2)
print("yeet")
tween2:Play()
wait(0.6)
local goal3 = {
CFrame = CFrame.new(-3621.40894, 1554.25354, 522.362305)
}

local tween3 = TweenService:Create(part2, tweenInfo2, goal3)
print("yeet")
tween3:Play()
wait(0.6)

local goal4 = {
CFrame = CFrame.new(-3622.90674, 1549.49878, 520.497253)
}

local tween4 = TweenService:Create(part2, tweenInfo2, goal4)
print("yeet")
tween4:Play()
wait(1)

local goal5 = {
CFrame = CFrame.new(-3636.53809, 1554.23535, 520.807922)
}

local tween5 = TweenService:Create(part2, tweenInfo2, goal5)
print("yeet")
tween5:Play()
end)

The script is inside of a surface gui text button which says launch

The very first tween before the explosion is another part which works perfectly fine. I tried putting a print before each time the tween plays. The timings are fine as they all printed within the right times. I then tried putting the wait after each tween:play() and set the wait time to the time it takes for the tween to finish. Still didn't work. I have been trying this for a while so help would be appreciated.

Answer this question