So, I am creating a breathing system for my game, The system works so far but I want to make it so when they stop holding G there will be a bit of a cooldown. How would I do this?
local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")
local debounce = false
UIS.InputBegan:Connect(function(Input,isTyping)
if isTyping then
return
elseif UIS:IsKeyDown(Enum.KeyCode.G) then
while UIS:IsKeyDown(Enum.KeyCode.G) do
if debounce then
wait(5)
debounce = false
return
end
--debounce = true
print("Breath")
game.ReplicatedStorage.BreathEvent:FireServer()
wait(1)
end
end
end)