Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I detect if the player jumped?

I'm not sure if Jump is boolean value because this doesn't seem to work.

local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

if humanoid.Jump.Value == true then
	print("the player has jumped")
end

1 answer

✓ Accepted answer

You are very close, try this:

Player = game.Players.LocalPlayer
Character = Player.Character or Player.CharacterAdded:Wait()

Humanoid = Character:WaitForChild('Humanoid')

local isJumping = false

Humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Jumping then
		if not isJumping then
			isJumping = true
		end
	elseif newState == Enum.HumanoidStateType.Landed then
		if isJumping then
			isJumping = false
		end
	end
end)

This uses StateChanged to detect when a player has started to jump, and when the player has landed.

1 comment

This discussion is preserved as it was. New answers, comments, and votes are closed.