Why does it say Humanoid is not there in player character?

Its my first time testing with context action service, I am actually testing as I don’t know context action service at all.

So the script is:

local contextservice = game:GetService("ContextActionService")
local function jumpplayer(actionname,keycode)
    game.Players.LocalPlayer.Character.Humanoid.Jump = true
    print(actionname)
    print(keycode)
end

contextservice:BindAction("JumpPlayer",jumpplayer(),true,Enum.KeyCode.J)

You have to use WaitForChild(“Humanoid”) instead of getting it directly.

This is because humanoid doesn’t load instantly when you join the game.

I tested it after 2 mins after joining, and I tried to change it like this:

local contextservice = game:GetService("ContextActionService")
local function jumpplayer(actionname,keycode)
    game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").Jump = true
    print(actionname)
    print(keycode)
end

contextservice:BindAction("JumpPlayer",jumpplayer(),true,Enum.KeyCode.J)

it says attempt to index nil with jump, it says there is no jump

You’re firing the function instead of passing it in, remove the ()

Also the 2nd return is the state of the input, not a keycode

1 Like

FindFirstChild is not the same as WaitForChild.

WaitForChild waits for the instance to load, while FindFirstChild just checks if the instance exists.

1 Like

It says not state of input:

Ok I changed it to Wait for child

What is your current code now?

local contextservice = game:GetService("ContextActionService")
local function jumpplayer(actionname,keycode)
    game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Jump = true
    print(actionname)
    print(keycode)
end

contextservice:BindAction("JumpPlayer",jumpplayer,true,Enum.UserInputType.Keyboard)

It works but, player don’t jump xd

Instead of using the Keyboard UserInputType, can’t you use the J keycode form before? Your issue of it not finding a humanoid was simply because it was calling the function instead of setting it

this happend if i used old script

do you know why player is not jumping?