My animation stops halfway through

Hey my animation stops halfway through and I don’t know how to fix it
I just need help

here’s the code

local UserInputService = game:GetService("UserInputService")

local prone = false
UserInputService.InputEnded:Connect(function(input, IsTyping)
	if  IsTyping then return end
	if input.KeyCode == Enum.KeyCode.X then
		if prone == false then
			local pronetrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.prone)
			pronetrack:Play()
			
			pronetrack.Stopped:Wait()
			prone = true
		else
			prone = false
		end
	end
end)

and the video
robloxapp-20220725-1754119.wmv (966.3 KB)

2 Likes

Maybe try this.

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

local UserInputService = game:GetService("UserInputService")
local prone = false

local pronetrack = humanoid.Animator:LoadAnimation(script:WaitForChild('prone'))

UserInputService.InputEnded:Connect(function(input, typing)
	if typing then return end
	if input.KeyCode == Enum.KeyCode.X then
		if not prone then
			prone = true
			pronetrack:Play()
			pronetrack.Stopped:Wait()
		else
			prone = false
		end
	end
end)

A couple of changes I did here, first instead of using humanoid:LoadAnimation, I used humanoid.Animator:LoadAnimation since this replaced the original and was the successor to it. I also added this script into StarterCharacterScripts inside StarterPlayer. Im pretty sure thats it.

Hope this helped out.
edit: IF your trying to make an animation that is an action, make sure that the AnimationPriority is set to Action so no errors could cause such a problem.

the AnimationPriority did it thank you

1 Like