Does anyone know how to fix this

my GUI have a delay if you keep clicking it how do i fix it
here is the script

local open = script.Parent.Parent.Parent.Open
local buttonFrame = script.Parent.Parent.Parent
local text = script.Parent.Parent.TextLabel

script.Parent.MouseButton1Click:Connect(function()

if open.Value == false then
	
	open.Value = true
	
	buttonFrame:TweenSize(UDim2.new(0.23, 0,0.109, 0))
	text.TextColor3 = Color3.new(0, 0, 0)
else
	open.Value = false
	
	buttonFrame:TweenSize(UDim2.new(0.21, 0,0.089, 0))
	text.TextColor3 = Color3.new(227, 210, 18)
	
	
end

end)

You need to add a second cooldown to wait for the Tweening process to finish. If you spam the button, it’s like you’re telling it to tween your GUIs, while the previous Tween process haven’t finished so the process overlaps (many tweenings process at once, giving illusion that it delays).

but i have another position tween can keep spamming it

What do you mean? What I’m trying to say is to make a cooldown for every time the button is pressed, like 5 seconds wait or something so the previous tweening process can finish first and not overlap.

Alternatively, you can add a part of the script that checks if a GUI is still tweening, so the player’s click doesn’t make it tween twice.

you might wanna edit the tween a little and also make sure another tween can override this one
by just adding true for example:

buttonFrame:TweenSize(UDim2.new(0.23, 0,0.109, 0), true)

apply this to both tweens and you’ll be good to go

1 Like

i tried this but

[ Unable to cast bool to token]

In that case, not the correct place for parameter.

It should be like this:

buttonFrame:TweenSize(UDim2.new(0.23, 0,0.109, 0), 2, true)

Note: Replace the 2 with what you want, it means 2 seconds (which is how long you want the Tween to be).

still
[Unable to cast bool to token]
i think that can only use in position tween

you must put EasingStyle and EasingDirection before that, like I said, edit your tween

for example:

buttonFrame:TweenSize(UDim2.new(0.23, 0,0.109, 0) Enum.EasingDirection.In,Enum.EasingStyle.Linear, 2 ,true)

instead of 2 you can put however you want your team to last

Don’t tweens stop if another tween begins on the same property?

did u type anything wrong with the enum cuz there is a error on enum

I did, oopsie

fixed line:

buttonFrame:TweenSize(UDim2.new(0.23, 0,0.109, 0), Enum.EasingDirection.In,Enum.EasingStyle.Linear, 2 ,true)
3 Likes

OMG, thx thats what i want and i learnt new stuff <3

1 Like