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)
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…
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.
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.
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 =)
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.
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.
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)
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.