Custom character animation not working

Hello everybody!

A while ago I had made an R6 custom walk animation for a game and implemented a script to use it.
It’s been a while since the last time I touched the project and noticed immediately that the animation wasn’t playing anymore.

This is the script to make the animation play:

-- First I have a table with all the animations I want to change
local UniversalAnims = {
	["Run"] = "rbxassetid://9910894856",
	["Walk"] = "rbxassetid://9910894856"
}
-- Then, on a server script, I change these animations when a player's character spawns
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		for anim, value in pairs(UniversalAnims) do
			if Character.Animate:FindFirstChild(string.lower(anim)) then
				Character.Animate[string.lower(anim)][anim.."Anim"].AnimationId = value
			end
		end
	end)
end)

The result is the player not playing any kind of animation while walking, but the default anims still work.

I have already thought about the new Strafe Blending being the issue, but I’m not sure where to start to try solving it.

1 Like

It is probably because the animations in the workspace aren’t loaded yet. You may be able to solve this by putting that code in the ServerStorage, or you could use a function like this:

local function GetAnimation(AnimationName)
    local Animation
    repeat
        Animation = Instance.new("Animation")
        Animation.Name = AnimationName
        Animation.AnimationId = "rbxassetid://9910894856"
    until Animation.Parent ~= nil

    return Animation
end

In your case, it would go something like this:

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Animations = {}
        for anim, value in pairs(UniversalAnims) do
            if Character.Animate:FindFirstChild(string.lower(anim)) then
                table.insert(Animations, {
                    AnimationName = anim,
                    Animation = GetAnimation(anim)
                })
            end
        end

        for _, Animation in pairs(Animations) do
            local AnimationName = Animation.AnimationName
            local Animation = Animation.Animation

            local AnimationTrack = Character.Animate[string.lower(AnimationName)][AnimationName.."Anim"]
            AnimationTrack.AnimationId = Animation
        end
    end)
end)
1 Like

Even with this code, it still does nothing:

There haven’t been any other errors / warning in the console either.

1 Like

I can’t help you then, sorry. I tried my best.

3 Likes

What I like to do when changing the default roblox animations is to simply run the game and copy roblox’s animate script under the player’s character and place it on StarterCharacterScripts, from there you can simply change the animation ids in the values.

3 Likes