Custom animation breaking

I was trying to change default animations based on Roblox’s official article:

The script I’m using:

local Players = game:GetService("Players")

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")

	for _, track in pairs(animator:GetPlayingAnimationTracks()) do
		track:Stop(0)
	end

	local animateScript = character:WaitForChild("Animate")
	animateScript.run.RunAnim.AnimationId = "rbxassetid://616163682"        -- Run
	animateScript.walk.WalkAnim.AnimationId = "rbxassetid://616168032"      -- Walk
	animateScript.jump.JumpAnim.AnimationId = "rbxassetid://616161997"      -- Jump
	animateScript.idle.Animation1.AnimationId = "rbxassetid://616158929"    -- Idle (Variation 1)
	animateScript.idle.Animation2.AnimationId = "rbxassetid://616160636"    -- Idle (Variation 2)
	animateScript.fall.FallAnim.AnimationId = "rbxassetid://616157476"      -- Fall
	animateScript.swim.Swim.AnimationId = "rbxassetid://616165109"          -- Swim (Active)
	animateScript.swimidle.SwimIdle.AnimationId = "rbxassetid://616166655"  -- Swim (Idle)
	animateScript.climb.ClimbAnim.AnimationId = "rbxassetid://616156119"    -- Climb
end

local function onPlayerAdded(player)
	player.CharacterAppearanceLoaded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

The script only works properly in the first few weeks, and currently it’s straight up broken.
Meanwhile I tested it on another local file and it is still fine.
How can I fix and what should I know to prevent similar situations like this?

For some reason Roblox’s animate script uses the animations inside of the script, rather than the ones inside the values.
Copy the animate script (while playtesting) and put it in StarterCharacterScripts. Then replace the animations from inside the script.

1 Like

Thanks, this will be definitely the final solution for this. But i wonder if there is a less messy way to do rather than this?

I don’t think so, but I could be wrong.