Humanoid's ChangeState "Jumping" Unaffected by JumpHeight

  1. What do you want to achieve?
    I am making a parkour vaulting script that when you jump onto a higher platform, you are given a short window of time to press the jump button and launch up really high.

  2. What is the issue?
    The function that changes the jump height of the player is being run, but the player never seems to exceed the default jump height.

  3. What solutions have you tried so far?
    I’ve tried adding a RunService.Heartbeat:Wait() before and after changing the jumpheight but that didn’t seem to do anything. I think it only stopped working after I added canVault and moved the code that runs the highjump() function to the Heartbeat.

All of the code is inside a localscript.

Video of code, it’s not letting me upload videos directly to the forum: - YouTube

local players = game:GetService("Players")
local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
local lp = players.LocalPlayer
local h = lp.Character.Humanoid
local hrp = lp.Character.HumanoidRootPart

local startY = h.Parent.HumanoidRootPart.Position.Y
local endY = h.Parent.HumanoidRootPart.Position.Y

local wantsToJump = 0
local canVault = 0
local canTry = true

function coyotejump()
	if canTry == true then
		wantsToJump = 0.2
		canTry = false
		print("coyotejump window triggered!")
	end
end

function highjump()
	warn("highjumping, conditions met")
	h.JumpHeight = 40
	h:ChangeState(Enum.HumanoidStateType.Jumping)
	h.JumpHeight = 13
	h.Parent.s_vault:Play() --this is a sound
end

h.Jumping:Connect(function(isActive)
	if isActive == true then
		print("jumped, point one set")
		startY = h.Parent.HumanoidRootPart.Position.Y
	end
end)

h.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Landed then
		print("landed, point two set")
		endY = h.Parent.HumanoidRootPart.Position.Y
		canTry = true
		if endY - startY > 2 then
			canVault = 0.15
			print("CanVault window triggered!")
		end
	end
end)

uis.JumpRequest:connect(coyotejump)

rs.Heartbeat:Connect(function(delta)
	wantsToJump -= delta
	canVault -= delta
	
	if wantsToJump > 0 and canVault > 0 then
		highjump()
		wantsToJump = 0
		canVault = 0
		canTry = true
	end
end)

Might be an issue in StarterPlayer if I remember correctly. I believe theres a property there that switches between using JumpHeight and JumpPower, your Humanoid might be utilizing JumpPower whilst youre changing the JumpHeight

2 Likes

Changed the game settings to use JumpHeight instead of Jump power, it still won’t change the jump height of the player didn’t affect the ChangeState jump. However, the line of code that changes the JumpHeight after the ChangeState() does work.

i litterally have the same issue, i will tell you if i find any solution

the issue

you should add a wait() in the middle of JumpHeight and ChangeState:

h.JumpHeight = 40
wait()
	h:ChangeState(Enum.HumanoidStateType.Jumping)
	h.JumpHeight = 13
	h.Parent.s_vault:Play() --this is a sound