Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.