If you spam-click the SHOP GUI button in my game, it'll stop working, you'll have to wait about 5-10 seconds before clicking it again, and it will work. It's kind of strange. I believe users would spam it out of frustration if it weren't working immediately. Which would just keep it non-working.
That is why I need to add a debounce, I've tried multiple ways although I can't get it to work. I'm very new to writing code, and I'm out of ideas! Can someone help me create a simple debounce? It should keep players from clicking the shop button for about 5 seconds after clicking once. Thank you very much!
Shop Button GUI script:
-- Shop tween local ShopFrame = script.Parent.Parent.ShopFrame local open = false script.Parent.MouseButton1Click:connect(function() if open == false then ShopFrame:TweenPosition(UDim2.new(0.311,0,0.15,0),'InOut','Quint',1.5) open = true else ShopFrame:TweenPosition(UDim2.new(0.311,0,1,0),'InOut','Quint',1.5) open = false end end)
a simple method should do
local ShopFrame = script.Parent.Parent.ShopFrame local open = false local busy = false script.Parent.MouseButton1Click:connect(function() if not busy then busy = true if open == false then ShopFrame:TweenPosition(UDim2.new(0.311,0,0.15,0),'InOut','Quint',1.5) open = true else ShopFrame:TweenPosition(UDim2.new(0.311,0,1,0),'InOut','Quint',1.5) open = false end wait(5) busy = false end end)