TweenService Stop Working?

Ahoy!
I’m making a weapon system but when I wanted to make a “Focus” effect with TweenService it stops working I don’t know why. :woman_shrugging:

I recreate the problem here:
FocusGuiProblem.rbxl

local Mouse = game.Players.LocalPlayer:GetMouse()
local TweenService = game:GetService("TweenService")

local Vignette = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Vignette")

local ZoomIn = TweenService:Create(Vignette, TweenInfo.new(0.5), {ImageTransparency = 0})
local ZoomOut = TweenService:Create(Vignette, TweenInfo.new(0.5), {ImageTransparency = 1})

local CanFocus = true

local function Focus(State)
	if State then
		ZoomOut:Cancel()
		ZoomIn:Play()
	else
		ZoomIn:Cancel()
		ZoomOut:Play()
	end
end

Mouse.Button1Down:Connect(function()
	
	if not CanFocus then return end
	
	Focus(true)
end)

Mouse.Button1Up:Connect(function()
	Focus(false)
end)

It gets stuck when clicking many times

1 Like

Any errors in the console? If so let me know please!

Nop, No errors.
You can test it in the file

I’d probably just ditch the ZoomOut:Cancel() and ZoomIn:Cancel(), I downloaded your file, did that and it works fine.

2 Likes

Oop I forgot to say what makes the problem :sweat_smile:
just spam click

Works fine once I deleted the :Cancel() so uh…

1 Like

its better to use :Pause() in my opinion
after i changed :Cancel() to :Pause() it worked perfectly (for one of my progects)

1 Like

You don’t even need :Pause() because the second tween just overrides the first one.

1 Like

true but sometimes it bugs so its better to do

1 Like

I added the :Cancel() because if you did “focus” and quickly removed it, the two tweens would start working at the same time and the whole screen would start blinking
Now I remove the :Cancel() and it seems to work now :woman_shrugging: Tysm!