Jump detecting is not consistent

This script I made is supposed to detect when the player jumps, but only works sporadically, not consistently.

local char = script.Parent
local hum = char:WaitForChild("Humanoid")

hum.Jumping:Connect(function(jumping)
	if jumping then
		print("jump")
	end
end)

Any ways to make this consistent?

1 Like

Yeah, detecting jumping on Roblox is notoriously painful and buggy…
Seems to be working fine for me though?

My code used is (in StarterCharacterScripts)

local localCharacter = script.Parent

local localHumanoid = localCharacter:WaitForChild("Humanoid")

local function onHumanoidJumping(isJumping)
	print(isJumping)
end

localHumanoid["Jumping"]:Connect(onHumanoidJumping)

Output looks something like thi
image
s:

Using the same thing, not consistent at all.

Well, you could try using HumanoidStateType and connect Jumping state, although it happens briefly, if you don’t want to check for how long player is actually jumping then that should fix the issue.

local localCharacter = script.Parent

local localHumanoid = localCharacter:WaitForChild("Humanoid")

local function onHumanoidStateChanged(currentState)
	local isJumping = currentState == Enum.HumanoidStateType.Jumping

	if isJumping then
		print("Player is jumping.")
	end
end

localHumanoid["StateChanged"]:Connect(onHumanoidStateChanged)

Heres the code for that.

I did make my own for this exception.

local char = script.Parent
local hum = char:WaitForChild("Humanoid")

hum.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Jumping then
		print("jump")
	end
end)

However this doesn’t seem to work either.

Did you modify character by any way? Because this feels like issue outside of detecting jumping

Well, I tried the script in both R15 and R6, both have consistency issues.

(R6 has less issues, but is still mildly inconsistent)
(Also, no edits whatsoever have been made, it is just a new baseplate with only that script)

I just noticed, you are running this script on server? Could you try running it on client? Maybe that is the issue.

1 Like

Changing to the client, it’s perfectly consistent now. Strange…

1 Like

It is quite expected, since Humanoid jumping is Client input.

1 Like

it’s because of the server-client boundary and ping or internet delay. when you jump, your roblox client actually “uses a RemoteEvent” (not actually a RemoteEvent, the server automatically replicates a player’s character in the client) to send your current position to the server. when firing a RemoteEvent from client to server and vice versa, there is a delay because of internet delay. this is also the reason why the perspective of a player walking in their device is different from another player’s perspective in a different device; when you start walking in your computer, you see that in another computer, there is a delay before you actually started walking. this is called replication

you can read more about replication and server-client boundary here

1 Like

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