I am trying to use custom animations for a custom character I made but the animations do not play.
I have this script running in ServerScriptService:
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")
animateScript.walk.WalkAnim.AnimationId = "rbxassetid://7891989420" -- Walk
animateScript.jump.JumpAnim.AnimationId = "rbxassetid://7892225376" -- Jump
end
local function onPlayerAdded(player)
player.CharacterAppearanceLoaded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
I tried using the animations in a different way by copying the default Animate script, adding it to the StarterCharacter in StarterPlayer, and changing the id’s to my custom animations but when I tested it the script had been reset to the default one in my character.
I replaced the Walk and Jump ids but it still does not work with my custom character. I tried putting it in the StarterCharacter and StarterCharacterScripts but neither of them worked.
It definitely seems to have overridden the walk and jump animations because when just using the regular character it stays still when doing those actions (I assume because it’s meant for a different rig it doesn’t know what to do?) so I guess it’s doing something.
If I use this Local Script by GnomeCode in StarterCharacterScripts:
-- Very basic walking animation script by GnomeCode
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
-- Remeber to select the animtion object and set the id to your own!
local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
humanoid.Running:Connect(function(speed)
if speed > 0 then
if not walkAnimTrack.IsPlaying then
walkAnimTrack:Play()
end
else
if walkAnimTrack.IsPlaying then
walkAnimTrack:Stop()
end
end
end)
and put an animation as a child named Walk with the id in it the animation plays.
-- Very basic walking animation script by GnomeCode
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
-- Remeber to select the animtion object and set the id to your own!
local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
humanoid.Running:Connect(function(speed)
if speed > 0 then
if not walkAnimTrack.IsPlaying then
walkAnimTrack:Play()
end
else
if walkAnimTrack.IsPlaying then
walkAnimTrack:Stop()
end
end
end)
humanoid.Climbing:Connect(function(speed)
--perform climbing anim here
end)
humanoid.Jumping:Connect(function(bool)
--perform jumping anim here
end)
That script is fairly simple to add to, just do like I, in the above.
Thanks! It works! It seems I also forgot to save my animation priority as movement. The script did not work until then even though I thought I had set it as movement it must not have saved. Good to know for the future!