Changing default animations at runtime?

Hey, and thanks for reading in advance.

I’m attempting to fiddle with my character’s default animations while in testing, and my animations remain unchanged after the fact. I’ve tried setting the Animation IDs of the objects inside the Animate script manually from the explorer window, also yielding no results. The default Animate script rigs up changed events on each of the Animation objects contained within, so I inserted a print to see if those were actually firing, and they weren’t.

Do changed events fire for clients if you edit an object from the client? Do I need to change the IDs from the server?

Code:

local UIS = game:GetService("UserInputService")
local RUN = game:GetService("RunService")
local RS = game.ReplicatedStorage

local Player = game.Players.LocalPlayer

local Character = script.Parent
local Root = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")

local Animator = Humanoid:WaitForChild("Animator")
local AnimScript = Character:WaitForChild("Animate")

--
local AnimSet = {
	idle = 6243307147,
	walk = 6410933149,
}

--
for name,id in pairs(AnimSet) do
	for _,obj in pairs(AnimScript[name]:GetChildren()) do
		if obj:IsA("Animation") then
			obj.AnimationId = "rbxassetid://"..id
		end
	end
end

(The animation playing on my avatar is the default.)

1 Like

yea i think you need to change it from the server because you’re changing it in the client

that doesnt affect it
the acctual problem is that the server need some time to load the animations and when that happens its too late since the older animation is played

thats why i use Humanoid.MoveDirection from changing idle to walk and back

This problem used to happen to me before. Well, the solution was the normal animations were already playing so I needed to stop them so the changed animation can played.

Here’s the code.
Also, use this code after you changed the id of animation.


local Character = script.Parent
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")

local PlayingAnimationTracks = Humanoid:GetPlayingAnimationTracks() --Getting every animation that is playing
for i, v in pairs(PlayingAnimationTracks)  do
     v:Stop()
end
2 Likes