How to disable jumping from spacebar

I don’t want to disable jumps entirely as i’m creating a custom jump for my character where you wind up slightly and then jump using Humanoid.Jump .I have tried unbinding it with ContextActionService,but it’s very unreliable and most of the time it does not work.

local ContextActionService =  game:GetService("ContextActionService")
ContextActionService:UnbindAction("jumpAction")

This is what I’m currently using.

Why use that when you can use,

local Humanoid = script.Parent:WaitForChild("Humanoid")
Humanoid.UseJumpPower = true
Humanoid.JumpPower = 0

I forgot to mention but the custom jump I have uses the roblox jump function,I am simply just making a regular jump but with a windup.Setting jump power to 0 will ruin this entirely.

1 Like

Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)

something like that, i forget the actual name of the jump state, i think its jumping

This also does not work.As I mentioned,I only want to unbind Spacebar from the jump action.It does work with ContextActionService,but only sometimes.

The way contextactionservice works is that it overrides the previously bound action. So technically you could bind jumpAction to an empty function an it would work.

The reason why your script only sometimes works is because the script runs too fast before the game loads. You can stop this by using:

if not game:IsLoaded then
    game.Loaded:Wait()
end
1 Like

In order to truly get it work I use CAS’s :Sink() attribute.

local noJump = "jumpAction"
CAS:BindAction(
	        noJump,
		function()
			return Enum.ContextActionResult.Sink
		end,
		false,
		unpack(Enum.PlayerActions:GetEnumItems()) --optional, I recommend but if it screws stuff up I'd remove 
	)
1 Like

I made an empty function and bound JumpAction to that and it worked.Thank you!

1 Like

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