Double Jump With animation not working

change this code local Animation = script:FindFirstChildOfClass("Animation"); to local Animation = humanoid:LoadAnimation(script:FindFirstChildOfClass("Animation")) again i think

I think it is already like this

what do you mean?
(30 chararrara)

the code is the same that i copied it from

can i see again what is the inside of the script

local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character = localPlayer.Character
local humanoid = character.Humanoid
 
local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.2
local DOUBLE_JUMP_POWER_MULTIPLIER = 1
local anim = humanoid:LoadAnimation(script:FindFirstChildOfClass("Animation"))

UserInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.Space then
			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)
				anim.Looped = false
				anim:Play()
			end
		end
	end
end)

local function characterAdded(newCharacter)
	hasDoubleJumped = false
	canDoubleJump = false
	anim.Looped = 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)

change the local anim = humanoid:LoadAnimation(script:FindFirstChildOfClass("Animation")) to local anim = humanoid:LoadAnimation(script:WaitForChild("the name of your animation"))

is it fixed?
(30 chars is bad jk)

I actually used this method and got it to work with animations, but the problem was that it played the animation after climbing and jumping, when it changes state in the jump request, load the animation and check if the humanoid exists, and put the animation inside the character, as animations inside the character (i think) are server-side so it will be:

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 = 1
local anim = humanoid:LoadAnimation(script:FindFirstChildOfClass("Animation"))

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 and humanoid then
		hasDoubleJumped = true
		humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
		local animation = Instance.new("Animation",character)
		animation.Name = "AnimNameHereIfNecessary"
		animation.AnimationId = "YouridHere"
		local anim = humanoid:LoadAnimation(animation) -- I made it's priority Action, but idk if it works when you set it to movement, you can try it
		anim:Play()
	elseif canDoubleJump and not hasDoubleJumped and not humanoid and character then
		humanoid = character:WaitForChild("Humanoid")
	end
end
 
local function characterAdded(newCharacter)
	character = newCharacter
	humanoid = newCharacter:WaitForChild("Humanoid")
	hasDoubleJumped = false
	canDoubleJump = false
	oldPower = humanoid.JumpPower
	anim.Looped = false
	anim:Play()
	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)

I tried the script and i change the animations from core to action or movement and it didn’t work

Ok guys i fixed it :smiley: finally I just needed to find a new script and stuff

1 Like