Userinputservice.inputbegan is firing twice

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)

image
screenshot of whats going on

thanks for reading

1 Like

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)

doesnt look like it worked, thanks for the reply though
image

oh wait hold on this prints not in the right place is it

edit

it was, thanks for the attempt

having the hardest time of my life trying to edit this post

Wait, does your script still fires twice?

sent a screenshot of the prints, it still fired twice, appreciate it though

1 Like

problem was that it was a character script, the connection would stay after death

1 Like

that was a prank apparently, my friend tested this and this isnt the case, but moving this to a playerscript fix it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.