Tweening problem mousebutton1up and mousebutton1down

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Make a button big when player holds the button down using mousebutton1down and tween it back to its original size when they release using mousebutton1up
  2. What is the issue? Include screenshots / videos if possible!
    Problem is that when i click it really fast it stays big

What this is doing here, theres is a collectionservice group of buttons that are doing this tween. I’m looping through them and making the event trigger for them

local thread = nil
local big = false
local rate = 1.5
for i, btnframe in pairs(BUTTONSIZINGGROUP) do
	if btnframe:IsA("TextButton") and btnframe.Parent.Name == "Front" then
		btnframe.MouseButton1Down:Connect(function()
			thread = nil
			wait(0.1)
			thread = coroutine.create(function()
				if big == false then
					btnframe.Parent.Parent:TweenSize(UDim2.new(btnframe.Parent.Parent.Size.X.Scale*rate, 0, btnframe.Parent.Parent.Size.Y.Scale*rate, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.3)
					big = true
				end
			end)
			coroutine.resume(thread)
		end)
		
		btnframe.MouseButton1Up:Connect(function()
			
			print("up")
			if thread ~= nil then
				coroutine.close(thread)
				thread = nil
				if big == true then
					big = false
					btnframe.Parent.Parent:TweenSize(UDim2.new(btnframe.Parent.Parent.Size.X.Scale/rate, 0, btnframe.Parent.Parent.Size.Y.Scale/rate, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.3)
				end
			end
		end)
	end
end

Try adding a half second - one second wait in between clicks.

Is that how big you are wanting it to get. What is the issue you are trying to fix now?

if you look at the video it gets smaller at some point at 0:09

So what is the issue you are having now?

i can still spam it and it will keep getting smaller/bigger

When you tween it after the mouse click is released are you putting it back to its original size?

yes i multiply the size by 1.5 when mousedown is fired, then when up is fired i divide by 1.5

first of all do this:
I would make you the modified script but it would take me a long time what you could do is:
make a variable which says true local debounce = true
then when the player presses the button it will be set to false debounce = false
then do a elseif not debounce then you will execute the code but making the button smaller or something like that more or less

Instead of dividing it get the original size of the button and paste it into the code. It may be a problem with it dividing. Or a denounce issue

Screen Shot 2023-02-11 at 7.30.50 PM

i get the original size when they the button is down

How would you get the original size when it’s down. Wouldn’t the original size be inside the UI’s size property?

i fixed the problem where its getting smaller, now i need to fix the problem where it keeps getting bigger if i spam

Try adding a debounce that only executes the code if it’s false. And when you click it and it gets bigger it sets to true and when it gets smaller it sets to false.

yeah i made a variable called big, set to true when the button is down, set to false when the button is up

Did you add a wait between the debounces checking?