I'm currently working on a menu Gui, and I'm trying to make it to where upon pressing T, the Gui will drop down into view, and upon pressing it again, the Gui will slide back up.
So far, it works perfectly, however the only problem is, I'm unsure how to prevent players from spamming the T key and making the Gui not work correctly.
(Also, all of the waits I'm using was my attempt to provide a cooldown.) Here's my code:
local userInput = game:GetService("UserInputService")
local background = game.Lighting.MenuBackground
userInput.InputBegan:Connect(function(input, gameProcessed)
wait(0.1)
if input.KeyCode == Enum.KeyCode.T and background.Enabled == false then
wait(0.1)
script.Parent.FrameXY:TweenPosition(UDim2.new(0.1, 0.1, 0.3, 0.1), "Out", "Bounce", 0.6)
wait(0.1)
background.Enabled = true
elseif input.KeyCode == Enum.KeyCode.T and background.Enabled == true then
wait(0.1)
script.Parent.FrameXY:TweenPosition(UDim2.new(0.1, 0, -0.4, 0), "Out", "Quad", 0.6)
wait(0.1)
background.Enabled = false
end
end)
Any help?

1 comment
This is something I actually tried before I wrote the current script. I couldn't get it to work, but I'll try again.