How to check if rig finished jumping

  1. What do you want to achieve? Keep it simple and clear!

so i was making an npc that could jump i just want to know if theres an event or a way to check if a rig has finished jumping.

2 Likes

Yes, the humanoid has a Jump property that is set to true while jumping and false when not, you could do :

repeat task.wait() until rig.Humanoid.Jump == false 

or whatever situation you would use it in.

1 Like

A better alternative is to use the humanoid.Jumped event and connect it to a function that checks the state type:

local char = script.Parent

local hum = char:WaitForChild("Humanoid")

function checkJumping()
	if hum:GetState() == Enum.HumanoidStateType.Jumping then
		repeat 
			task.wait()
		until hum:GetState() == Enum.HumanoidStateType.Landed
		if hum:GetState() == Enum.HumanoidStateType.Landed then
			print("Finished Jumping")
		end
	end
end

hum.Jumping:Connect(function(IsJumping)
	if IsJumping then
		checkJumping()
	end
end)
1 Like

I don’t recommend polling for something as simple like this. It’s the last thing you want to do. It really doesn’t matter anyways because .Jump is only true when the player is holding down the space bar. It wouldn’t work.

Polling isn’t really ever something good to do, unless it’s a value that there is no events for checking changed signals on.

1 Like

Alternatively to polling if you wanted to make it as simple as possible, you could use the hum.StateChanged event:

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

hum.StateChanged:Connect(function(state)
	if state == Enum.HumanoidStateType.Landed then
		print("Finished Jumping")
	end
end)
1 Like

i only used repeat task.wait for hum:getstate() == enum.HumanoidStateType.Landed and it works really well thanks

2 Likes

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