How can I change between animations mid game?

Hello! Thanks for taking time to check my question.
I added a scripts to make my character double jump but it looks weird to use the normal animation twice, so i thought i could use a frontflip animation for the secont jump but i dont know how to.
I got the double jump script HERE
Any ideas on how to do it? Help is greately appreciated.
Im a newbie so i would appreciate if you explained with sticks and stones haha thanks.

I see what you mean here. Doing it with the normal animation looks weird. I don’t really know this stuff but I think it has something like :RunAnimation or something. Hopefully someone experienced will come past and help you out!

1 Like

thanks :smile: it is pretty hard

I actually did this with the animation, so basically, when you change the state of the character to the jumping state, you can change the animation, just as you change the state, play the animation, the animation has to be movement or action, I did it like this:

local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local character
local humanoid
local animation = Instance.new("Animation") -- Create a new animation
animation.Name = "Flip"
animation.AnimationId = "" -- Id here
animation.Parent = character
 
local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.2
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)
        humanoid:LoadAnimation(animation):Play() -- Play the animation
	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)

but this has a problem, sometimes when you jump and climb onto ladders, when you jump off the ladder, it plays the animation, I don’t know why this happens, and I don’t remember the code entirely because I deleted the script, so this might not work entirely

1 Like

It Works!
Only thing is you have to be very quick or it uses the normal animation
Thanks!