Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a custom jump key (and unbind the original one)???

Asked by 4 years ago

Hello, I have done due diligence, googled, and searched the Developer Hub to no avail. I cannot figure out how to bind a new key to Jumping. I am NOT requesting you to script it for me. I am asking for an explanation of what I'd need to do to make the script myself.

2 answers

Log in to vote
1
Answered by 4 years ago

Hello there.

You must use ContextActionService. It is used for binding actions to keys.

You can first unbind the jump action by using ContextActionService:UnbindAction("jumpAction").

Then, you can use UserInputService to detect the input when the player jumped.

Example Code:

local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")

ContextActionService:UnbindAction("jumpAction")

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.LeftControl and gameProcessedEvent then
        local character = game:GetService("Players").LocalPlayer.Character

        if character then
            if character.Humanoid.Health > 0 then
                character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            end
        end
    end
end)

How it Works

You must first unbind the "jumpAction" action. Then, you must use the InputBegan event of UserInputService to detect when the client makes an action. Next, you must check if the KeyCode is the KeyCode you want and that the player isn't in chat. I used LeftControl as the jump key. Then, you must check if the character isn't nil and if the character's health is above 0. If it is, the humanoid will then jump.

Please accept this answer if it helped.

0
How did you know the Jump Action was called jumpAction? Are there documentation of the default ROBLOX actions? Void_Frost 571 — 4y
0
Also, do you unbind on the client or server? Void_Frost 571 — 4y
0
Unbind it on the client. There's a BindedActions dropdown on the developer console and it tells you the name of all actions. youtubemasterWOW 2741 — 4y
Ad
Log in to vote
1
Answered by
MemezyDev 172
4 years ago
Edited 4 years ago

What I think that will work is use a body force or something like that and make it move the player upwards, then just set the jump power to 0. It is probably not the best way but it should work.

0
This isn't really the answer I'm looking for, because I might apply the same principle to other things, such as walking, and I don't really want a hacky solution. This would probably work,though. There has to be a clean way to do it with the already-present jump function, right? Void_Frost 571 — 4y
0
yea probs but im not that good with scripting so thats how i thought it would work lmao MemezyDev 172 — 4y

Answer this question