Adding default animations isn't working at all

I’m trying to replace all default animations with custom ones. However the code in this DevHub article isn’t working at all.

Script found in DevHub
local Players = game:GetService("Players")
 
local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
 
	for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
		playingTracks:Stop(0)
	end
 
	local animateScript = character:WaitForChild("Animate")
 
end
 
local function onPlayerAdded(player)
	player.CharacterAppearanceLoaded:Connect(onCharacterAdded)
end
 
Players.PlayerAdded:Connect(onPlayerAdded)
My script
--!strict

local Players = game:GetService("Players")

local PlayerDefaultAnimations = {}
PlayerDefaultAnimations.__index = PlayerDefaultAnimations

function PlayerDefaultAnimations.new()
	local self = {}
	
	setmetatable(self, PlayerDefaultAnimations)
	return self
end

function PlayerDefaultAnimations:ListenForPlayers()
	Players.PlayerAdded:Connect(function(player)
		player.CharacterAppearanceLoaded:Connect(function(character)
			local humanoid = character:WaitForChild("Humanoid")
			
			for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
				playingTracks:Stop(0)
			end
			
			local animateScript = character:WaitForChild("Animate")
			animateScript.walk.WalkAnim.AnimationId = "rbxassetid://5752798317"
		end)
	end)
end

return PlayerDefaultAnimations

As you can see, I used the same code as the DevHub article and this happens:

(the custom animation isn’t being played)


image

Weirdly enough the animation id changes so the script is working but the animation isn’t being played by the character.


I haven’t tried anything else, why this useless question even exists… DevForum is the first place to get help from…

1 Like

You could try forking the original Animate script and then putting it into StarterCharacterScripts? You can easily change IDs in there.

Still doesn’t work.

three zero characters

That’s really weird. Changing the IDs in the animate script should always work. Are you sure you put it into StarterCharacterScripts?

Yeah I did.

I always use the Animate script method, and it has always worked. Could you please tell me what did you do to the animate script? Maybe you forgot one or two steps. Happened to me too.
Also, the method Roblox gives doesn’t work. I tried it multiple times, and it never worked, so I doubt that will help you out.

I coped the ‘Animate’ script and pasted it into StarterCharacterScripts. Then I changed walk to

walk = 	{ 	
				{ id = "http://www.roblox.com/asset/?id=5752798317", weight = 10 } 
			},

Oh, I see where the problems here are.

  1. The “Walk” animation isn’t really used on PC platforms. Basically, the walk animation starts playing when the humanoid’s walkspeed goes from 0 to 6. What you’re looking for here is the “Run” animation.
  2. You forgot to change the AnimationId of the animation inside the Animate.walk element.

    Change the one in the picture, and the one in the script.

Remember to change the run animation tho, not the walk, as the walk is most likely used on mobile devices as the player can choose their speed with the movement controller.
One important thing to remember is that if you put the same IDs on the walk and run animations, for some unknown reason, the animation won’t replicate to the server (aka other players won’t see it).

Hope this helped! If you have any questions just ask =)

1 Like

I changed run animation as well and still doesn’t work.

1 Like

When you say doesn’t work, do you mean it reverts to the default one, or do you mean no animation is being played?

Oh-, at this point I don’t really know how to help you out. It’s very weird it doesn’t work. Remember to change back the “Walk” animation to the original ID, and change the “Run” animation to your custom animation. If you are sure you’ve done everything I told you then that sounds really weird.

image
Roblox resets it back to my avatar’s animation.

1 Like

Hmm, could you just type something like ‘return’ in your animation script, put that in StarterCharacterScripts? Let me know if that removes the animation or not. Also, if you could check if inside the script and see if it automatically reverts the script or if the script gets updated?

Oh, most important thing: ensure the script you’re putting in StarterCharacterScripts is a LOCAL script, not a server script.


There seems to be some AllowCustomAnimations thing but I can’t write to it using the command bar.

1 Like

Did you create any script that has animateScript.run.RunAnim.AnimationId = "rbxassetid://507767714"?
If so, disable them or remove that line of code, as that might be the problem.
Also, in the script, change this:

        run = 	{
        				{ id = "http://www.roblox.com/asset/?id=507767714", weight = 10 } 
        		}, 

To this:

run = 	{
        				{ id = "http://www.roblox.com/asset/?id=YOURANIMATIONID", weight = 10 } 
        		}, 

(Change “YOURANIMATIONID” with, ofc, your animation ID)

1 Like

You shouldn’t have to do that, simply putting it in the StarterCharacterScripts folder should overwrite the default script. Let me look into it.

Could you confirm that your game is R15 only?

i think that when you change the scale in game settings it does that

1 Like

The game is R15 only. I already added my own animation and removed all other scripts that change that animation.

I’ll probably have to go to bed now if this doesn’t start to get solved. Otherwise my mom will probably get mad at me. I hate my time zone. 12:06 AM already.

1 Like

That’s really weird. Can you verify that your hierarchy looks like this, and Animate has no children?

Screen Shot 2020-09-28 at 6.11.00 PM

1 Like

image

1 Like