Double jump not working

Double jump not working

Script:

local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local canjump = true
local havejumped = false
local humanoid = player.Character.Humanoid

humanoid.StateChanged:Connect(function(old,new)
    if new == Enum.HumanoidStateType.Landed then
        canjump = true
        havejumped = false
    elseif new == Enum.HumanoidStateType.Freefall then
        canjump = true
    else
        canjump = true
    end
end)

uis.JumpRequest:Connect(function()
    if canjump == true then
        if havejumped == false then
            humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            havejumped = true
        end
    end
end)

Why are you not using the script provided in this article you linked? it basically got everything you need!

I am trying to practice it, as I want to make a double boost plane, the script in the hub is for players, so I am practicing this to try later, tell why my script is not working pls

I think because that!

local canjump = true ←

if new == Enum.HumanoidStateType.Landed then
canjump = true ←

You could make!

local canjump to false!

you made both true

1 Like

why is the player able to double jump even if canjump is false

local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local canjump = true
local humanoid = player.Character.Humanoid

humanoid.StateChanged:Connect(function(old,new)
    uis.JumpRequest:Connect(function()
        if new == Enum.HumanoidStateType.Freefall and canjump == true then
            canjump = false
            humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
        elseif new == Enum.HumanoidStateType.Landed then
            canjump = true
        end
    end)
end)

may not work. tried my best
May cause that!
don’t add canjump == true.
Example:
if new == Enum.HumanoidStateType.Freefall then
canjump = false

Try that.

local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local canjump = true

plr.Character.Humanoid.StateChanged:Connect(function(old,new)
  uis.JumpRequest:Connect(function()
  if new == Enum.HumanoidStateType.Freefall then
    canjump = false
        plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
             elseif new == Enum.HumanoidStateType.Landed then
               canjump = true
         end
    end)
end)

did not work he can infinitely go up

Well tried my best!

Try to check Output.

or try changing that to! like you did.
if new == Enum.HumanoidStateType.Freefall and canjump == true then

 elseif new == Enum.HumanoidStateType.Landed and canjump == false then
            canjump = true
            print("bruh")
        end

its printing bruh even thought i did not land, thats a roblox studio bug isnt it?

local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character
local humanoid
 
local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.2
local DOUBLE_JUMP_POWER_MULTIPLIER = 2
 
function onJumpRequest()
	if not character or not humanoid or not character:IsDescendantOf(workspace) or
	 humanoid:GetState() == Enum.HumanoidStateType.Dead then
		return
	end
	
	if canDoubleJump and not hasDoubleJumped then
		hasDoubleJumped = true
		humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end
 
local function characterAdded(newCharacter)
	character = newCharacter
	humanoid = newCharacter:WaitForChild("Humanoid")
	hasDoubleJumped = false
	canDoubleJump = false
	oldPower = humanoid.JumpPower
	
	humanoid.StateChanged:connect(function(old, new)
		if new == Enum.HumanoidStateType.Landed then
			canDoubleJump = false
			hasDoubleJumped = false
			humanoid.JumpPower = oldPower
		elseif new == Enum.HumanoidStateType.Freefall then
			wait(TIME_BETWEEN_JUMPS)
			canDoubleJump = true
		end
	end)
end
 
if localPlayer.Character then
	characterAdded(localPlayer.Character)
end
 
localPlayer.CharacterAdded:connect(characterAdded)
UserInputService.JumpRequest:connect(onJumpRequest)
1 Like

Yes I know this script is in Double jumping page, but I asked why my script does not work?

Compare it with the script found from the official documentation page.

Its the same but here debounce don’t work

First of all, the script from the hub don’t work

Second of all, my script works on r15 games, I did not know this does not work on r6 games