ContextActionService not running at begin of input when I'm pressing another button

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make a blocking feature for my RPG game with contextactionservice but I also have a sprinting feature.

  1. What is the issue? Include screenshots / videos if possible!

If I try blocking while sprinting it doesn’t do anything, but my block function only runs at the end of the input, which is when the player stops blocking.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried checking the userinputstate contextactionservice returns, it only returns Enum.UserInputState.End.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

This script only includes the block script, it is client sided. It might be a bit messy as this is an old game I’m picking back up.

local ts = game:GetService("TweenService")

	char = chr

function Block(AN, IS)
	if IS == Enum.UserInputState.Begin then
		char.Humanoid.WalkSpeed = 0
	elseif IS == Enum.UserInputState.End then
		if game.Players.LocalPlayer.Stats.WalkSpeed:FindFirstChild("Block") then
		local adder = 0
		for i, v in pairs(game.Players.LocalPlayer.Stats.WalkSpeed:GetChildren()) do
			adder += v.Value
		char.Humanoid.WalkSpeed = adder

ctx:BindAction("Block", Block, true, Enum.KeyCode.F, Enum.KeyCode.ButtonY)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Edit: All good, I managed to fix it.

If you made a game, you can only post in the Showcase category if you received 100+ favourites. Games with a large amount of favourites can be moved to the Showcase category on request.

If you’re looking for a group or wanting to recruit people to your group, please use the Recruitment category instead.