Changing the keybind to jump

How do you change the keybind from the spacebar to left click instead? Or atleast, any keybind? I’m doing this to recreate something related to Baldi’s Basics.

I’m not sure if there even is a way to change the keybind for jumping though, but any help is appreciated!

Perhabs this could help you?Dunno

1 Like
local plr = game.Players.LocalPlayer
local Humanoid = plr.Character:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input:InputObject)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end)

This should work. Note that this does not unbind Space from jump, it just assigns the left click to make the player jump.

1 Like

This is from one of my games.
It handles key bind holding and acts like the default Roblox jumping.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")

local Player = Players.LocalPlayer :: Player
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid

local NewKeybind = Enum.KeyCode.E
local IsJumpKeyHeld = false

local GroundedStates: {[Enum.HumanoidStateType]: boolean} = {
	[Enum.HumanoidStateType.Running] = true,
	[Enum.HumanoidStateType.RunningNoPhysics] = true,
	[Enum.HumanoidStateType.Landed] = true,
}

ContextActionService:BindAction("CustomJump", function(_, InputState: Enum.UserInputState)
	IsJumpKeyHeld = InputState == Enum.UserInputState.Begin
end, false, NewKeybind)

local HeartbeatConnection = RunService.Heartbeat:Connect(function()
	if IsJumpKeyHeld and GroundedStates[Humanoid:GetState()] then
		Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end)
2 Likes