I tried to set up a debounce for whenever the mouse button is pressed, but for some reason it just keeps repeating the code, completely ignoring the debounce. Is there anything I did wrong here?
--Variables
local folder = script.Parent
local player = game.Players.LocalPlayer
local rf = script.Parent:WaitForChild("RemoteEvent")
local chargeRemote = script.Parent:WaitForChild("Charging")
local fireRemote = script.Parent:WaitForChild("Fire")
local shooting = false
local uis = game:GetService("UserInputService")
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local holdingMouse = false
local debounce = false
--Anims
local charge = folder:WaitForChild("Charge")
local fire = folder:WaitForChild("Fire")
local chargeTrack = hum:LoadAnimation(charge)
local fireTrack = hum:LoadAnimation(fire)
--Functions
if not debounce then
uis.InputBegan:Connect(function(input, gameProccessedEvent)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
debounce = true
print("working")
wait(.2)
local rh = character:WaitForChild("RightHand")
holdingMouse = true
chargeTrack:Play()
rf:FireServer(rh, character)
--Charge the ki
rf.OnClientEvent:Connect(function(cb)
--[[chargeTrack.KeyframeReached:Connect(function(pose)
if pose == "Pause" and holdingMouse then
chargeTrack:AdjustSpeed(0)
end
end)]]
if holdingMouse then
while holdingMouse do
wait()
--chargeRemote:FireServer(character)
end
end
end)
--When the mouse is released, fire
mouse.Button1Up:Connect(function()
--[[if chargeTrack.Speed == 0 then
chargeTrack:AdjustSpeed(1)
else
return false
end]]
while chargeTrack.IsPlaying do
wait()
end
holdingMouse = false
fireTrack:Play()
end)
end
end)
end

4 comments
"if not debounce then" should be right before "debounce = true"
i dont think it matter wherever its put, as long as its there
No the debounce check needs to be inside the event, not outside of it. it does matter
Yeah, Arctanh is correct. Right now the debounce bool does nothing, since it is only gating setup of the connection, which only happens once anyways.