We use cookies on this site to enhance your user experience

Jump Cooldown

Jump Cooldown

Sep 07 2018, 2:38 AM PST

The following sample will require a one second cooldown after a Humanoid has landed before it is able to jump again.

To try this sample, place it inside a LocalScript in StarterCharacterScripts|StarterPlayer.StarterCharacterScripts.

local character = script.Parent

local JUMP_DEBOUNCE = 1

local 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
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
		end
	elseif newState == Enum.HumanoidStateType.Landed then
		if isJumping then
			isJumping = false
			wait(JUMP_DEBOUNCE)
			humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
		end
	end
end)