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)
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.