Animation Script Help

Hello Developers! I’m trying to do run a script to run an animation, but for an unknown reason is not working, and I have no errors on the output.

  1. What do you want to achieve? Keep it simple and clear!
    I want to do run a script then it runs an animation of the NPC.
  2. What is the issue? Include screenshots / videos if possible!
    The animation is not working on the NPC, and I have no errors on the output.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried searching in youtube, but it didn’t help.

I want to do an animation run in a NPC, I’m using a script but is not working, and I have no errors on the output.

I hope you can help me.
Kindest regards,
Waum_a.


print "Loading animation...."
wait (5)
local Animation = script.Parent.Animation1
local aim = script.Parent.AnimationController:LoadAnimation(script.Parent.Animation1)


	
	aim:Play()
 
print "Sucefully loaded animation."

2 Likes

Is this animation part of Roblox? Is it a custom animation that you are playing?

print ("Loading animation.... "
wait(5)
local Animation = script.Parent.Animation1
local humanoid =  -- You have to get the Humanoid of NPC You're trying to Play the Animation On
local AnimationTrack =  humanoid:LoadAnimation(Animation)


AnimationTrack:Play()

print("Successfully loaded animation.")
5 Likes

I uploaded it to roblox. Is mine.

1 Like

Did you put the correct animation ID?

2 Likes

image

Yes, I put the correct animation ID.


print ("Loading animation.... ")
	wait(5)
	local Animation = script.Parent.Animation1
	local humanoid =  script.Parent.Humanoid
	local AnimationTrack =  humanoid:LoadAnimation(Animation)
	
	
	AnimationTrack:Play()
	
	print("Successfully loaded animation.")

Now I have no errors on the output but is not working.

Could you show me a picture of the contents of the NPC ?

We can even rearrange the script

local Animation = script.Parent.Animation1
local humanoid = script.Parent:WaitForChild("Humanoid")
local AnimationTrack = humanoid:LoadAnimation(Animation)

print("Loading Animation... ")
wait(5)

AnimationTrack:Play()

print("Successfully loaded animation.")
1 Like
local AnimationId = 0 --Put your animation id here.
local NPC = script.Parent --I put parent as the example.
local Humanoid = NPC:WaitForChild("Humanoid")

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid//"..AnimationId
local Track = Humanoid:LoadAnimation(Animation)
Track:Play()

print("Successfully ran animation.")
2 Likes

image , “Animations” script is the script to run the animation.

Also the animation is mine, and is off-sale. That can be a problem?

The sale doesn’t affect anything. It’s whether or not you did the code right

2 Likes

I used Moon Animator, maybe that is the problem?

Still not working. I sent you the picture of the contents of the NPC.

Did you try 50Alpha’s Solution ?

Try This

while true do
wait(5)
AnimationTrack:Play()
end
1 Like

Of course! I did! I tested it but it didnt worked.

Is not working it seems there is a big problem.

The “Success” doesn’t print. I don’t know why.