How to fix animations not properly playing

  1. What do you want to achieve? Keep it simple and clear!
    I want to have several movement modes of animation for my custom mech character.
    -Walking
    -Dash Forward
    -Dash Left
    -Dash Right
    -Dash Backward

  2. What is the issue? Include screenshots / videos if possible!
    The animations for the Dash Right and Dash Forward do not hold position even though they are set to looped in the workspace/explorer.
    https://gyazo.com/cd529eee7adfc817007f62ea00e18116
    https://gyazo.com/f7cde7c7df712a649222858e3d0bccba

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried verifying that the animations are playing which they appear to do so in the output.
    I’ve made sure to check the IDs are correct.
    I’ve made sure they are set to looped to hold the position theyre put into.
    Its probably worth noting at some point the forward dash animation worked properly too but somehow broke when I changed the script.
    I’ve already tried changing animation priority of affected animations but no change.

Here’s the code I used

local UserInputService = game:GetService("UserInputService")

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
print("Found Humanoid")

local walkAnimation = script:WaitForChild("Walk")
local walkAnimationTrack = humanoid.Animator:LoadAnimation(walkAnimation)


local jumpUnitForwardAnimation = script:WaitForChild("JumpUnitForwardTransition")
local jumpUnitForwardTrack = humanoid.Animator:LoadAnimation(jumpUnitForwardAnimation)

local jumpUnitForwardLoopedAnimation = script:WaitForChild("JumpUnitForwardLooped")
local jumpUnitForwardLoopedTrack = humanoid.Animator:LoadAnimation(jumpUnitForwardLoopedAnimation)

local jumpUnitStrafeLeftAnim = script:WaitForChild("JumpUnitStrafeLeft")
local jumpUnitStrafeLeftTrack = humanoid.Animator:LoadAnimation(jumpUnitStrafeLeftAnim)

local jumpUnitStrafeRightAnim = script:WaitForChild("JumpUnitStrafeRight")
local jumpUnitStrafeRightTrack = humanoid.Animator:LoadAnimation(jumpUnitStrafeRightAnim)

local jumpUnitReverseAnim = script:WaitForChild("JumpUnitReverse")
local jumpUnitReverseTrack = humanoid.Animator:LoadAnimation(jumpUnitReverseAnim)
print("Found animations")
print("Loaded animations")

local skimming = false --Bool to see if the character should dash or not

local function isShiftDown()
	return UserInputService:IsKeyDown(Enum.KeyCode.LeftShift)
end

local function isDDown()
	return UserInputService:IsKeyDown(Enum.KeyCode.D)
end

local function isADown()
	return UserInputService:IsKeyDown(Enum.KeyCode.A)
end

local function isSDown()
	return UserInputService:IsKeyDown(Enum.KeyCode.S)
end


humanoid.Running:Connect(function(speed)
	if speed > 0 then
		print("Speed high")
		if not walkAnimationTrack.IsPlaying or jumpUnitForwardTrack.IsPlaying or jumpUnitStrafeRightTrack.IsPlaying or jumpUnitStrafeLeftTrack.IsPlaying then
			
			if skimming == true then
				walkAnimationTrack:Stop()
				jumpUnitForwardTrack:Play()
				if jumpUnitForwardTrack.IsPlaying then
					print("Forward Playing")
				end
				print("Skimming forward")
				humanoid.WalkSpeed = 100
			else
				walkAnimationTrack:Play()
				jumpUnitForwardTrack:Stop()
			
				print("Walking forward")
				humanoid.WalkSpeed = 25
			end
			print("Playing")
		end
	--elseif speed > 0 and ShiftDown then
	--	if walkAnimationTrack.IsPlaying then
	--		walkAnimationTrack:Stop()
	--		jumpUnitForwardTrack:Play()
	--	else
	--		jumpUnitForwardTrack:Play()
	--	end
	else
		if walkAnimationTrack.IsPlaying or jumpUnitForwardTrack.IsPlaying then
			walkAnimationTrack:Stop()
			jumpUnitForwardTrack:Stop()
			humanoid.WalkSpeed = 25
			print("Stopped")
		end
	end
end)


local function Input(input, gameProcessedEvent)
	if isShiftDown() then
		if skimming == false then
			skimming = true
		else
			skimming = false
		end
	end
	if isDDown() and skimming == true then
		jumpUnitStrafeRightTrack:Play()
		jumpUnitStrafeLeftTrack:Stop()
		jumpUnitReverseTrack:Stop()
		if jumpUnitStrafeRightTrack.IsPlaying then
			print("Strafe Right Playing")
		end
		print("Skimming Right")
	elseif isADown() and skimming == true then 
		jumpUnitStrafeLeftTrack:Play()
		jumpUnitStrafeRightTrack:Stop()
		jumpUnitReverseTrack:Stop()
		if jumpUnitStrafeLeftTrack.IsPlaying then
			print("Strafe Left Playing")
		end
		print("Skimming Left")
	elseif isSDown() and skimming == true then
		jumpUnitReverseTrack:Play()
		jumpUnitStrafeLeftTrack:Stop()
		jumpUnitStrafeRightTrack:Stop()
		if jumpUnitReverseTrack.IsPlaying then
			print("Reverse Playing")
		end
		print("Skimming back")
	else
		jumpUnitStrafeLeftTrack:Stop()
		jumpUnitStrafeRightTrack:Stop()
		jumpUnitReverseTrack:Stop()
	end
end



UserInputService.InputBegan:Connect(Input)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Is the AnimationPriority on “Action”? If not, set it to that.

I have tried that… Its even in the picture, it didnt work. I just dont get it…