Autojump for PC, Console, and (etc.). Not just Mobile

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Auto jump for PC, Console. Not just mobile players

  2. What is the issue? Include screenshots / videos if possible!
    Not really sure where to start when coding such a script.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Looked around and I don’t see anything for autojump for other platforms besides Mobile.

I’m looking for something like this where the character autojumps or walks up blocks without manually jumping. https://twitter.com/WobblyToothLtd/status/1744044084459647034?t=9E0M0xlSWH3vy6JC_GUVmA&s=19

I think you’re gonna need Raycasting here.

Try casting a ray from the HumanoidRootPart every RunService.RenderStepped and see if that works.

--LocalScript

local runService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local params = RaycastParams.new()
params.FilterDescendantsInstances = char:GetDescendants()
params.IgnoreWater = true
params.RespectCanCollide = true
params.FilterType = Enum.RaycastFilterType.Exclude

local function autojump()
    local origin = hrp.CFrame.Position
    local direction = hrp.CFrame + (hrp.CFrame.LookVector * 1.5)

    local result = workspace:Raycast(origin, direction, params)
    if result then
        hum:ChangeState(Enum.HumanoidStateType.Jumping)
    end
end

runService:BindToRenderStep("Autojump", 2000, autojump)
1 Like

Thanks, I was wondering if I should’ve used raycasting but wasn’t really sure. I’ll go test this out.

1 Like

Works great, but had to fix a issue and added a if player is in air check. I corrected the direction calculation by ensuring it properly adds a Vector3 to another Vector3 and added a condition to check if the character is on the ground before attempting to jump, to prevent unexpected behavior.


-- LocalScript

local runService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local params = RaycastParams.new()
params.FilterDescendantsInstances = char:GetDescendants()
params.IgnoreWater = true
params.RespectCanCollide = true
params.FilterType = Enum.RaycastFilterType.Exclude

local function autojump()
	local origin = hrp.Position
	local direction = hrp.CFrame.LookVector * 1.5

	local result = workspace:Raycast(origin, direction, params)
	if result and hum.FloorMaterial ~= Enum.Material.Air then
		hum:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end

runService:BindToRenderStep("Autojump", 2000, autojump)

Nice, looks good. Just mark whatever post is most helpful as solution. I’m glad you found my script helpful.

Edit: I just saw you marked one, sorry :sweat_smile:

1 Like

Your good mate lol. Thanks for the help tho

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.