Cannot jump after dying

I made a script that makes a jump cooldown but after dying you cannot jump anymore:
Heres the script:

local character = script.Parent
local hum = character.Humanoid


local isJumping = true
hum.StateChanged:Connect(function(landed)

	if landed == Enum.HumanoidStateType.Landed then
		
		
		task.wait(1)
		isJumping = true
		hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	else
		isJumping = false
		hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	end

	
end)
1 Like

Maybe the enabled state to jump was disabled when you died, so you cant enable it again when landing, maybe adding a check if humanoid dies, to restore the state.
And the script was disabling Jump everytime any other state occurs, so I added an elseif statement to only disable jump when player is actually jumping, not running or anything else:

local character = script.Parent
local hum = character.Humanoid

local isJumping = true
hum.StateChanged:Connect(function(state)
	warn(state)
	if state == Enum.HumanoidStateType.Landed then
		warn("jumping to true")
		task.wait(1)
		isJumping = true
		hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	elseif state == Enum.HumanoidStateType.Jumping then
		warn("jumping to false")
		isJumping = false
		hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	end
	
end)

hum.Died:Connect(function()
	warn("jumping to true after dead")
	hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end)
1 Like

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