InputEnded not firing sometimes

Hello. I am trying to script a block system but I am having problem with one thing. I want the block to stop when player doesn’t hold F. Sometimes, when you just tap the button the block stays active since InputEnded does not fire. How can I fix that?

UIS.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if stunned.Value then return end
	if silenced.Value then return end
	if health <= 0 then return end
	if using.Value ~= "" then return end
	if not equipped.Value then return end
	if dashing.Value then return end
	if db then return end
	if UIS:IsKeyDown(Enum.KeyCode.Q) then return end	
	if input.KeyCode == Enum.KeyCode.F then
		if blockDB then return end
		if blockHealth.Value > 0 then
			remote:FireServer("Block", tool, combatVariables, nil, "blockOn")
		end
		
	end
	
end)

UIS.InputEnded:Connect(function(input, gpe)
	if gpe then return end
	if stunned.Value then return end
	if silenced.Value then return end
	if health <= 0 then return end
	if not equipped.Value then return end

	if input.KeyCode == Enum.KeyCode.F then
		if using.Value ~= "Blocking" then return end
		if blockBrokenVar.Value then return end
		if blockHealth.Value > 0 then
			remote:FireServer("Block", tool, combatVariables, nil, "blockOff")
		end
	end
end)

As I said, when player taps the key the InputEnded doesn’t fire. I guess thats an engine limitation so I need alternative approaches.

My guess is one of two things

    1. You are constantly spamming the key, in which it wouldnt fire.
    1. It is firing, except one of your many if statements is returning, hence completely stopping it from doing whatever.

Now I believe from your description its probably the second option, so I would begin by debugging, in that I mean print when any of these things return to narrow down where its returning, thus allowing you to find the issue and deal with it

1 Like

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