Help with swapping animations in runtime

So I need a little help with swapping the players animations while the game is running, as I’m having some issues.

Yes, the animations are changing, however only after the player does a different animation.

Heres a video showing the issue:

I’m using mostly vanilla roblox animate code, with some slight modifications to get the idle animation swapping correctly. The run animation just doesn’t seem to work for some odd reason, however.


After writing this, I made some additional changes and now the animation just weirdly blends until I again, do a different animation before.

My modded code:

-- Setup animation objects
function scriptChildModified(child)
	local fileList = animNames[child.Name]
	if (fileList ~= nil) then
		configureAnimationSet(child.Name, fileList)
		
		--// This is added on
		if currentAnim == "idle" then
			playAnimation(currentAnim, 0.2, Humanoid)
		elseif currentAnim == "walk" then
			currentAnimTrack:Stop()
			--// This causes weird blending, even though I stop the previous track
			switchToAnim(animTable["run"][1].anim, "run", 0.2, Humanoid)
		end
		
	end	
end

script.ChildAdded:connect(scriptChildModified)
--script.ChildRemoved:connect(scriptChildModified)

By the way; I have tried swapping the animation IDs and (what I’m currently doing) just replacing the instance.

I need the animation to change while it’s playing as it causes the game to really look weird if it doesn’t.

And while I’m here, the walking animation isn’t replicating over to the server properly, it seems to be blending with the idle animation even though they’re on different animation priorities.

1 Like

change the character’s humanoid state

1 Like

Thanks, works just fine now.

Also, what state is the best to change to or does it not matter?

for me, it would be landed since its reliable

it really doesn’t matter though

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