ContextActionService Disabling Jumping

For some reason whenever I try to jump the player won’t jump on ground.

local function DoubleJumpHandler(action, inputState, inputObj)
	if action == "DoubleJumping" then
		if inputState == Enum.UserInputState.Begin then
			if hum:GetState() == Enum.HumanoidStateType.Freefall then
				if not doubleJumped then
					doubleJumped = true

					local jVel = Instance.new("BodyVelocity", root)
					jVel.Name = "jVel"
					jVel.MaxForce = Vector3.new(0, 1e8, 0)

					jVel.Velocity = char:FindFirstChild("HumanoidRootPart").CFrame.UpVector * jumpHeight

					game:GetService("Debris"):AddItem(jVel, 0.03)
					game:GetService("RunService").RenderStepped:Connect(function()
						if hum:GetState() ~= Enum.HumanoidStateType.Freefall and doubleJumped then
							doubleJumped = false;
						end
					end)
				end		
			end
		end
	end
end

ContextActionService:BindAction("DoubleJumping", DoubleJumpHandler, false, Enum.KeyCode.Space, Enum.KeyCode.ButtonA)

Well, it looks like every time the player jumps, it’s calling that script, which only allows them to jump in the air.

1 Like

Yep, I’m aware of that. I’m mostly familiar with UserInputService and this is my first proper time using ContextActionService which is quite embarrassing Lol. I’m just quite confused on how I get this to run only when they’re in the air.

Use the Humanoid FloorMaterial property to determine the material of the floor they are walking on. If they are not standing anything it will be Enum.FloorMaterial.Air

1 Like

I just found out about “Enum.ContextActionResult.Pass”. I ended up returning it by doing:

return Enum.ContextActionResult.Pass

It literally binds a key to multiple functions and it solved my problem but thanks eitherway for the help!

1 Like