Disable Auto Jumping for PC ( TUTORIAL )

Hello, I have written some code to better improve Roblox’s Jumping Mechanics by disabling auto jumping completely and also adding a slight delay before you can jump again.

The problem with the previous tutorials on this same function is that they are now outdated and no longer working as intended or not at all. Another problem is that they were not designed for modern Lua structure or incorrect use of functions.

Let’s start off with defining our Services.

--[[ SERVICES ]]
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

Now that our services have been defined let’s move on to defining our Character and Humanoid which we will use later on.

--[[ CHARACTER ]]
local Character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

The method I use to define the Character variable is quite simple and less likely to break the script if it runs before the character has a chance to be added. Now we have to define our more dynamic variables.

--[[ VARIABLES ]]
local CanJump = true
local LastJumpTime = 0

CanJump will determine if we can jump later on, now we have to write the functions in order for this script to work as intended.

--[[ JUMPING ]]
UserInputService.JumpRequest:Connect(function()
	if CanJump then
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
		LastJumpTime = tick()
		CanJump = false
	else
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	end
end)

This is not enough, so we will add a loop that will continuously check we if can jump or else we will only be able to jump once since we’re not actually changing the CanJump variable.

--[[ CHECKING IF YOU CAN JUMP ]]
RunService.Heartbeat:Connect(function()
	if not CanJump and tick() >= LastJumpTime + 1 and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Space) then
		CanJump = true
	end
end)

Using heartbeat is more reliable since instead of firing every time a new frame is rendered it fires every time the “tick” changes ( Roughly 60 times per second ). If you want to change the Jump Delay you will need to change “1” from tick() >= LastJumpTime + 1 to any number ( In seconds ).

FULL CODE HERE!!!

--[[ SERVICES ]]
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

--[[ CHARACTER ]]
local Character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

--[[ VARIABLES ]]
local CanJump = true
local LastJumpTime = 0

--[[ JUMPING ]]
UserInputService.JumpRequest:Connect(function()
	if CanJump then
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
		LastJumpTime = tick()
		CanJump = false
	else
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	end
end)

--[[ CHECKING IF YOU CAN JUMP ]]
RunService.Heartbeat:Connect(function()
	if not CanJump and tick() >= LastJumpTime + 1 and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Space) then
		CanJump = true
	end
end)

Make sure to place this code inside of a [ LocalScript ] in [ StarterPlayer > StarterPlayerScripts ]

Any mistake you wish to point out feel free to bring it to my attention, I also welcome you to give me your feedback on this script or if you have a more reliable solution for this please do so by replying. If you also need further assistance for this code please notify me!

4 Likes

But can’t you turn it off from the main menu Roblox already offers?

2 Likes

Hello, unfortunately that only applies to Mobile devices, this is the only currently known way to disable Auto Jumping for I would presume all devices including Console!

I’ll check on my PC and tell you if it’s on PC too if I remember

Haha, I already know it doesn’t work because this is the primary reason to which I made this code.