Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animation stops when walking?

I would like to change the animation priority to play over walking and jumping. I currently have it so that when E is pressed the player does a frontflip, but the moment they start walking it stops.

I had read this: https://developer.roblox.com/en-us/api-reference/enum/AnimationPriority

I tried doing this. However it returns an error.

local flip = Instance.new("Animation")
flip.AnimationPriority = 2

3 comments

0

Enum.AnimationPriority.Action ?

0

I think that is what I need. How would I incorporate that into the script? If you answer below, I can accept your answer :)

0

I tried "Enum.AnimationPriority.Action = flip" , but this gives the error "Action cannot be assigned to "

1 answer

Answer: Just add an event to the humanoid that detects when the player jumps, and play the animation. Rather than doing the front-flip when they press E.

Note: I did this in a LocalScript in StarterCharacterScripts

Code:

local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")

local isJumping = false

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Jumping then
		if not isJumping then
			isJumping = true
			print("Started jump..!")
			
			--Play animation here
			
		end
	elseif newState == Enum.HumanoidStateType.Landed then
		if isJumping then
			isJumping = false
			print("Ended jump..!")
			
--[[ You will stop the animation here if you only want it to play during the jump, if you want it to finish playing out then don't. ]]
			
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.