Issues with animations and Animations Speed

Hello Dev Forum

Im not much of an Animator and is my first time scripting Animations for a “Movement System”. The issue im having is that the animations get stuck in the first frame when I first play them and when I play them for a second time it runs normaly. This issue started when I added the :AdjustSpeed() and so Im wondering if anyone can help me solve this issue.

Function that handle the Animations:

function playAnimation(animationId, speed)
	
	if humanoidAnim ~= nil then
		humanoidAnim:Stop()
		humanoidAnim = nil
	end
	
	humanoidAnim = Humanoid:LoadAnimation(animationId)
	
	local trackspeed = humanoidAnim.Length / speed
	
	humanoidAnim:Play()
	
	humanoidAnim:AdjustSpeed(trackspeed)
	
end

if anyone need the entire code let me know I got no issues passing it.

1 Like

shouldn’t you try preloading the animations before playing them?
I think LoadAnimation yields.

(try creating a function to load an animation, run it for each animation at the start of the game, and then pass the animation and speed to playAnimation function.)

also try not dividing the animation length. (1 is normal speed)

Thanks to your response I came out with a solution, so in the movement system script, I create and set the IDs of the animations. What I did to fix the issue was that I created a folder with the animations inside the ReplicatedStorage and created a Local Script inside ReplicatedFirst. Inside the Local Script I preloaded the animations using the ContentProvider Service and works fine now. Thanks to ur answer I came up with it.

local CP = game:GetService("ContentProvider")

local animationsFolder = game.ReplicatedStorage:WaitForChild("MovementsAnimations")

CP:PreloadAsync(animationsFolder:GetChildren())
2 Likes

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