Ui getting stuck

Hello, can anyone help me figure out why my UI gets stuck if I hover over it to quickly? Here is an example: https://gyazo.com/bf41ed854c4f4581c1382cd085e9ce2e

local db = false

script.Parent.MouseEnter:Connect(function()
	if not db then
		db = true
	--script.Parent:TweenSize(UDim2.new(0.146, 0,0.117, 0), "In", "Quad", .1)
		script.Parent.Icon:TweenPosition(UDim2.new(1.092, 0,-0.008, 0), "Out", "Back", .15)
		wait(.1)
		db = false
	end
end)

script.Parent.MouseLeave:Connect(function()
	if not db then
		db = true
	--script.Parent:TweenSize(UDim2.new(0.137, 0,0.11, 0), "In", "Quad", .1)
		script.Parent.Icon:TweenPosition(UDim2.new(1.029, 0,-0.008, 0), "In", "Quad", .1)
		wait(.1)
		db = false
	end
end)

Personally would use TweenService so you can do .Completed:Wait() for better accuracy.
^ Edit: Or just use the callback (as shown here)
It may be because override is automatically set to false. Try this & see if it still gets stuck:

script.Parent.Icon:TweenPosition(UDim2.new(1.029, 0,-0.008, 0), "In", "Quad", 0.1, true)

Like @Itz_Louu mentioned, use the overide

script.Parent.MouseEnter:Connect(function()

    script.Parent.Icon:TweenPosition(UDim2.new(1.092, 0,-0.008, 0), "Out", "Back", .15, true)

end)

script.Parent.MouseLeave:Connect(function()

    script.Parent.Icon:TweenPosition(UDim2.new(1.029, 0,-0.008, 0), "In", "Quad", .1, true)

end)

Thank you for the useful information. I appreciate you helping me

1 Like