Custom Character Animation Script not Working

I’m having issues on getting an animation working on a custom character

Currently, the script just doesn’t work:

local contentprovider = game:GetService("ContentProvider")
AnimationFolder = game.Workspace.Animations
TestIdle = AnimationFolder.Testidle.AnimationId
contentprovider:PreloadAsync(TestIdle)


game.Workspace.kingdomkind.Animate.walk.WalkAnim.AnimationId = TestIdle

What i’m trying to get it to do is to go into the workspace, to the local character (i just put my name here for testing) then down the animate script to the walk, then the walk anim and then its id and then i want to change that to TestIdle (it’s actually a walk animation). Here’s a video of it working within the animation editor (the last keyframes must have imported wrong and that’s why they are slow but that’s an issue for another day)

Can anyone inform me what is wrong with my script? Any feedback would be appreciated!

1 Like

Not sure if what you posted is the full script or not but the “AnimationFolder” variable isn’t defined as well as “TestIdle”.

Here’s my fixed version:

local contentprovider = game:GetService("ContentProvider")
local AnimationFolder = game.Workspace.Animations
local TestIdle = AnimationFolder.Testidle.AnimationId
contentprovider:PreloadAsync(TestIdle)
game.Workspace.kingdomkind.Animate.walk.WalkAnim.AnimationId = TestIdle

oops, i forgot the local but it still doesn’t work

I’m not too familiar with the ContentProvider service as I don’t use it but I’ll provide an example of a script I’d use in your situation and maybe it’ll help, also it would be helpful to provide some error logs.

local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")--get humanoid

local newAnimation = Instance.new("Animation")--create a new animation object or put in the location of an existing one

newAnimation.AnimationId = "rbxassetid://" .. "0000000000" --your animation id here

local newTrack = humanoid:LoadAnimation(newAnimation)--load the animation onto the humanoid

newTrack:Play()--play your animation

I see, you did it incorrectly. Try this

local ContentProvider = game:GetService("ContentProvider")
local AnimationFolder = game.Workspace.Animations
ContentProvider:PreloadAsync(AnimationFolder:GetDescendants())

local TestIdle = AnimationFolder.Testidle.AnimationId
game.Workspace.kingdomkind.Animate.walk.WalkAnim.AnimationId = TestIdle