Issue with Double Jump script and animation not working

I found a double jump script that should play animation and double jump but it doesn’t work. My game is in R6 and I don’t if that changes anything but here is what I have

local player = game.Players.LocalPlayer
local character = player.Character
repeat wait()
	character = player.Character
until character

local hum = character:WaitForChild("Humanoid")
local flip = hum:LoadAnimation(script.JumpAnimation)
local sound = script.Sound

local doubleJumped = false
local canDoubleJump = false
local jumpMultiplier = 15
local defaultJump = hum.JumpPower

local cooldown = false

game:GetService("UserInputService").JumpRequest:Connect(function()

	if canDoubleJump == true and doubleJumped == false and cooldown == false then
		hum.JumpPower = defaultJump * jumpMultiplier
		doubleJumped = true
		hum:ChangeState(Enum.HumanoidStateType.Jumping)
		flip:Play()
		sound:Play()
		wait(flip.Length)
		flip:Stop()
		sound:Stop()
	end

end)

hum.StateChanged:Connect(function(oldState, newState)

	if newState == Enum.HumanoidStateType.Landed then
		hum.JumpPower = defaultJump
		doubleJumped = false
		canDoubleJump = false
		hum.JumpPower = defaultJump * jumpMultiplier
		if flip.IsPlaying then
			hum:ChangeState(Enum.HumanoidStateType.Ragdoll)
		end
	elseif newState == Enum.HumanoidStateType.Freefall then
		wait(0.2)
		canDoubleJump = true
	elseif newState == Enum.HumanoidStateType.Ragdoll then
		wait(2)
		hum:ChangeState(Enum.HumanoidStateType.GettingUp)
	end

end) 

Screenshot 2023-12-06 203125

2 Likes

Is the only issue with the animation?

Being R6 may change if the animation would work, it has to be created in R6 to work in R6. You might also want to change the AnimationPriority if you haven’t already, because your animation might be getting trumped by Roblox default aniimations.

1 Like

the issue is the double jump itself isn’t working, i’m only jumping once. And yes the animation isn’t playing.

1 Like

See, you’re using “wait(flip.Length)” which is buggy and will stop the animation instantly. What you have to do is use “flip.Stopped:Connect(function()” instead.

2 Likes

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