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.
local AnimObj = Instance.new("Animation")
AnimObj.AnimationId = "rbxassetid://6304090639"
local animation = humanoid:LoadAnimation(AnimObj) -- This is the error line
animation:Play()
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.