I am making a script that when the player holds down their left mouse button, it tweens a gui and they can interact with it, and when they release the left mouse button, the gui disappears. The problem I am having is if I hold the left mouse button and release too fast, the gui just stays on the screen instead of disappearing.

This is my code:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local circle = script.Parent.DummyCircle

mouse.Button1Down:connect(function()
	circle:TweenSize(UDim2.new(0,250,0,250),1,4,0.7)
end)

mouse.Button1Up:connect(function()
	wait(0.01)
	circle:TweenSize(UDim2.new(0,0,0,0),1,4,0.7)
end)

Here is a video of what happens

https://gyazo.com/2a7c0f58f0e2a52000109753ea86d6e3

2 comments

0

you should try to set the gui position before moving, so you ensure where it is

0

That is not the problem I am having. The problem is that the gui stays on the screen after I release the left mouse button if I press and left go of the left mouse button too fast.