Need Help Creating Script To Make Animation Play

I have this double jump script and I’m wanting to have a double jump animation play when actually doing the double jump. So I need the first jump animation to play and then the double jump animation. If any can help with this it’d be a huge help. Here is what I got:

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.1 -- The time before you can do another jump
local DOUBLE_JUMP_POWER_MULTIPLIER = 1 -- The amount of times you can jump in the air 
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)

Why not just make the player jump here?

	if canDoubleJump and not hasDoubleJumped then
		hasDoubleJumped = true
		humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
		-- Player Jumps Here
	end

And to below the -- Player Jumps Here,

local plrAnimator = humanoid:FindFirstChildOfClass("Animator")
if plrAnimator then
	local JumpAnimation = plrAnimator:LoadAnimation(--The Jump Animation)
	JumpAnimation:Play()
end

Can you send the whole script written out like how you made it, because I’m having trouble with it

if canDoubleJump and not hasDoubleJumped then
	hasDoubleJumped = true
	humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
	-- Player Jumps Here
	local plrAnimator = humanoid:FindFirstChildOfClass("Animator")
	if plrAnimator then
		local JumpAnimation = plrAnimator:LoadAnimation(--The Jump Animation)
			JumpAnimation:Play()
	end
end

Some stuff is underlined do you know what’s wrong?

This might come off as rude but, do you even know how to script? Because if you don’t I can’t really help you without literally teaching you every single thing you need to know, so if you don’t know how to script, I suggest you first learn how to script a little bit first.

Yeah, I just looked at it again and realised how much of a moron I am, sorry lol

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