Stopping a tween

I just decided to just check if closeTween isn’t nil.

local closeTween

function module.TweenOpen()
	if closeTween then
		closeTween:Pause()
		closeTween = nil
	end
	
	local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out, 0, false, 0)
	local tween = TweenService:Create(EggDisplayGui.MainFrame.UIScale, tweenInfo, {Scale = 1})
	tween:Play()
end

function module.TweenClose()
	local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
	closeTween = TweenService:Create(EggDisplayGui.MainFrame.UIScale, tweenInfo, {Scale = 0})
	closeTween:Play()
	
	closeTween.Completed:Connect(function()
		if closeTween then
			EggDisplayGui.Enabled = false
			EggDisplayGui.Adornee = nil
		end
	end)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.