im trying to make a parry and when trying to use the inputbegan event for userinput service itll fire twice, ive added a debounce and looked at posts on this topic but they either were left unanswered or didnt help my situation
heres my code (ive stripped away pretty much everything that wasnt necessary, still produces same problem of firing twice)
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local debounce = false
userInputService.InputBegan:Connect(function(input)
if player.Character:FindFirstChildOfClass("Tool") and input.KeyCode == Enum.KeyCode.F and not debounce then
debounce = true
task.wait(0.1)
debounce = false
end
end)
Try using the return statement, I updated the script for you
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local debounce = false
userInputService.InputBegan:Connect(function(input)
if player.Character:FindFirstChildOfClass("Tool") and input.KeyCode == Enum.KeyCode.F then
if debounce then
return
end
debounce = true
task.wait(0.1)
debounce = false
end
end)