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

[Tween service] Why isn't Tween:Pause() not working?

Asked by 5 years ago

I'm making a spill system and when the touched ended is fired i want the tween to cancel. Heres my code

local spill = script.Parent
local TweenService = game:GetService("TweenService")




local partChanges = {
    Size = Vector3.new(0.07, 1.15, 1.15),
    Position = Vector3.new(-53.214, 15.743, -5.75)

}


local tweenInfo = TweenInfo.new (
    5,
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.InOut,
    0,
    false,
    0.1

)

local tween = TweenService:Create(spill, tweenInfo, partChanges)



script.Parent.Touched:Connect(function(touch)

    if touch.Parent.Name == "Mop" then
        tween:Play()


    end
end)

script.Parent.Touched:Connect(function(touch)

    if touch.Parent.Name == "Mop" then

        tween:Pause()


    end
end)



1 answer

Log in to vote
0
Answered by 5 years ago

Your code is not working because you are using .Touched twice!

local spill = script.Parent
local TweenService = game:GetService("TweenService")




local partChanges = {
    Size = Vector3.new(0.07, 1.15, 1.15),
    Position = Vector3.new(-53.214, 15.743, -5.75)

}


local tweenInfo = TweenInfo.new (
    5,
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.InOut,
    0,
    false,
    0.1

)

local tween = TweenService:Create(spill, tweenInfo, partChanges)



script.Parent.Touched:Connect(function(touch)

    if touch.Parent.Name == "Mop" then
        tween:Play()


    end
end)

script.Parent.TouchEnded:Connect(function(touch)

    if touch.Parent.Name == "Mop" then

        tween:Pause()


    end
end)



Use TouchEnded, not Touched.

Ad

Answer this question