How do i stop this UI tween?

Hello developers, so im currently trying to find a way to a size tween for a proximity prompt when the player stops holding the button. This is currently what i have gotten up to so far but im not sure on how to stop the bar tween when the “PromptButtonHoldEnded” function begins. Any help please?

local info = TweenInfo.new(
	1,
	Enum.EasingStyle.Cubic,
	Enum.EasingDirection.Out,
	0,
	false
)

local Goals =
	{
		Size = UDim2.new(1.01, 0, 0.93, 0); 
	}
ProximityPromptService.PromptButtonHoldBegan:Connect(function(promptinstance, player)
	if promptinstance.Parent:FindFirstChild("Prompt") then
		if promptinstance.Parent.Prompt:FindFirstChild("Bar") then
			local bar = promptinstance.Parent.Prompt:WaitForChild("Bar")
			local ButtonTween = game:GetService("TweenService"):Create(bar.Bar, info, Goals)
			
			ButtonTween:Play()
		end
	end
end)

ProximityPromptService.PromptButtonHoldEnded:Connect(function(promptinstance, player)
	if promptinstance.Parent:FindFirstChild("Prompt") then
		if promptinstance.Parent.Prompt:FindFirstChild("Bar") then
			local bar = promptinstance.Parent.Prompt:WaitForChild("Bar")
			
			bar.Bar.Size = UDim2.new(0, 0, 0.93, 0)
		end
	end
end)

You can stop a tween using Tween:Cancel()

2 Likes

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