How do i detect when a player jumps

I’ve tried everything but most stuff just dont work.

4 Likes
Humanoid.Jumping:Connect(function(IsJumping)
    if IsJumping then
        -- do something
    end
end)
5 Likes

That barely even works because sometimes it doesnt even fire

I would go for the remote event approach where you have a client script listening to the space bar key.

1 Like

Where did you put the code? This event should be in a LocalScript which will always work.

It doesnt work in server scripts?

Here is a simple server side jump detection:

local Players = game:GetService("Players")


Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local hum :Humanoid = char:WaitForChild("Humanoid")
		
		hum:GetPropertyChangedSignal("Jump"):Connect(function()
			if(hum.Jump == true) then
				
				print("Jumped!")
				
			end
		end)
		
	end)
end)
1 Like

This is unreliable, exploitable and not a good idea.

Here are your options:

  • Listen to changes of the Jump property of the humanoid (as seen in @EthicalEye’s example)
  • Using an event such as Humanoid.Jumping such as @Giorgi311’s example
  • Using an event such as StateChanged
  • Listening to changes on the FloorMaterial property (I wouldn’t recommend this as it may also register if a player is falling)
  • Manually detecting changes in the HumanoidRootPart’s Y position, and if it goes higher than a certain threshold then you can assume its jumping.

I would consider looking over the earlier examples as those are the standard ways of going about this and would likely work best with a bit of tinkering

2 Likes

All of those examples only really work on client sided scripts

Apologies for the oversight when making a suggestion. Yours are really better.

Using an event such as StateChanged

Listening to changes on the FloorMaterial property (I wouldn’t recommend this as it may also register if a player is falling)

Manually detecting changes in the HumanoidRootPart’s Y position, and if it goes higher than a certain threshold then you can assume its jumping.

I believe these can be done server-sided.

1 Like

I don’t think roblox lets you read floormaterial property on the server. I’m gonna just do the script on the client instead of a server.

Nope, everything here should work on the server, even FloorMaterial. Please double check before jumping to conclusions

I already double checked everything. You are the one who hasnt tho.

The script written by @EthicalEye has some major issues that cant be fixed on the server.

and the code made by @Giorgi311 doesnt work on the server either but he did tell me that it only works on the client so i understand now

Try this dirty method that I just made up if the methods above doesn’t work for your use case.

local character = script.Parent :: Model
local humanoid = character:FindFirstChildWhichIsA("Humanoid") :: Humanoid
local animate = character:WaitForChild("Animate") :: LocalScript
local animator = humanoid:WaitForChild("Animator") :: Animator

animator.AnimationPlayed:Connect(function(animationTrack)
	local animation = animationTrack.Animation
	if animation and animate.jump.JumpAnim.AnimationId == animation.AnimationId then
		print("Jump detected!")
	end
end)
1 Like