Double Jump Anim Error

So I have a double jump script. The double jump works fine but the animation isn’t playing. I even made an R15 and R6 version and changed the default avatars to R6/R15 but nothing helps.

The script is a localscript in StarterPlayerScripts
Here it is

local localPlayer = game.Players.LocalPlayer
local character
local humanoid
local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.1
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)



		local AnimObj = Instance.new("Animation")
		AnimObj.AnimationId = "6304090639" 

		local animation = humanoid:LoadAnimation(AnimObj) -- This is the error line
		animation:Play()
	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)
 

The error message:
[ Invalid animation id ‘<error: unknown AssetId protocol>’: ]
Error line:

local animation = humanoid:LoadAnimation(AnimObj)

Sorry to bother with something that’s probably super easy to solve but I’ve tried every solution I could think off and I just can’t seem to fix it. I don’t want to have to redo the entire script because it works just fine, it’s just the animation that’s the problem.

Is the animation set to an action

What do you mean?
It’s supposed to play when the second jump is activated. But it doesn’t.

try putting an animation in side the script and then put the id of the animation in there and then add to the script

local Animation = script.Animation

Animation:Play()

Hmm… Something isn’t right. I’ll try some alternatives with the idea you gave me because the double jump still works but the animation isn’t.

when exported the animation was it set to action

I don’t think so… I’m not really sure what that means but I know I exported it the same way I exported my other animations.

Error Message:
Play is not a valid member of Animation “Players.ZIMOPlayzRBLX.PlayerScripts.DoubleJump.Animation”

The error is with the animation id.

Whatever line this code is on

local AnimObj = Instance.new("Animation")
		AnimObj.AnimationId = "6304090639" 

		local animation = humanoid:LoadAnimation(AnimObj)

Replace the AnimationId with rbxassetid://6304090639

That should fix the error

1 Like

Ohhhhhhh I didn’t even think of that…

your forgetting rbxassetid://

	local AnimObj = Instance.new("Animation")
	AnimObj.AnimationId = "rbxassetid://6304090639" 

	local animation = humanoid:LoadAnimation(AnimObj) -- This is the error line
	animation:Play()
1 Like

It works thanks a lot. But I have one other problem. It seems like whenever I double jump too late the animation doesn’t want to play. It’s like when I jump and start to fall but then jump again it doesn’t play, but when I double jump quick it does. I know you solved the problem that I already posted but sometimes the animation doesn’t play.

you have to change the priority of the animation. Try them all out to see which one works best.

1 Like

What do you mean by the priority?
Also by “try them all” do you mean like R15 and R6? If so then I tried that as well and it does the same thing.

no, in the animation editor before you save there’s a option that’s like “Set Priority” you change that to one of the options.

Oh okay . I’ll see what I can do
Oh I see. So what do I set it to?

try them all out. I dont really make animations so keep picking random ones until the issue resolves.

1 Like

I switched it to Movement and it worked! Thanks a lot.
What should I mark as the solution?

set my code fix local AnimObj = Instance.new(“Animation”)
AnimObj.AnimationId = “rbxassetid://6304090639”

local animation = humanoid:LoadAnimation(AnimObj) -- This is the error line
animation:Play()

since that was the main issue

1 Like

this one I should be more exact lol