Updating default animations after changing AnimationIds within the Animate Script

Hi,

Basically, my goal is to be able to, from without the Animate script, update the animationid’s of the relevant Animation instances (idle, walk, jump, fall, etc.), and then somehow cause the script to use the new animations. My current approach is to have an event which is detected from within a fork of the Animate script, which then does the relevant code magic.

My current problem is that the Animate script is a piece of hellish spaghetti code, and I haven’t the faintest clue of where to start. Solutions that I’ve found thus far don’t work during runtime, or are not seamless (ie. require the user to stop entirely), or don’t replicate properly.

If anyone accustomed to dealing with roblox’s Animate script has any ideas of how I could accomplish this, I would greatly appreciate your support.

Thank you.

Its pretty simple, Animate script has values inside with the IDs of those animations and emotes the player has. Are named exactly like that idle (which has 2 animations), walk, run, jump, fall etc.

Your function just need to access the animate script, then the values, and change the animation ID.
Be sure to Stop() the previous animation track for example the idle track, so the change is inmediate.

Look, inside the Animate script while playing:
image


To stop the previous anim track, use Animator:GetPlayingAnimationTracks(), it returns an array of the current tracks, and stop the one you want.

the problem is that this doesn’t work. the animations do not change when I do this.

I’ve found a solution! (no thanks to any of you). I will be typing it here for those that come after me.

In a fork of the Animate script, I added this code before the final loop.

local possiblestates = {
	Running = onRunning,
	Died = onDied,
	Jumping = onJumping,
	Climbing = onClimbing,
	GettingUp = onGettingUp,
	Freefall = onFreeFall,
	FallingDown = onFallingDown,
	Seated = onSeated,
	PlatformStanding = onPlatformStanding,
}
script.Override.Event:Connect(function()
	for i, v in ipairs{"idle", "walk", "run", "jump", "fall"} do
		animNames[v][1].id = script[v]:FindFirstChildWhichIsA("Animation").AnimationId
	end
	for name, fileList in pairs(animNames) do 
		configureAnimationSet(name, fileList)
	end
	possiblestates[Humanoid:GetState().Name](Character.HumanoidRootPart.Velocity.Magnitude)
end)

I don’t know exactly which parts are required, but if you do this (and remember to add an event instance, remote or otherwise) and fire the event after you’ve changed the animationids, it works.

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