Animation wont run

I’ve tried to search for an solution. It still wont work out. I have a Moon animation saved to roblox which is supposed to run on a NPC when you grab a flashlight.

local ghost = {}

ghost.firstAppearence = function(c)
	local humanoid = c.Humanoid	
	local anim = humanoid:LoadAnimation(script:FindFirstChildOfClass("Animation"))

	anim:Play()
end

return ghost

This is a module in ServerScriptService which would run it. the c is the Character which is referring to the ghost that would walk through this area:


image
This is the character thats supposed to walk through the room. But nothing happends. Am i doing something wrong?

1 Like

Are you calling the function?

ghost.firstAppearence()

Yes,
image
The character is defined as the spirit

Potential problems which mite be the issue:

Character variable is nil.
Loading a R15 anim or R6 rig.

Also, LoadAnimation on the humanoid has been deprecated for months now.

Use Animator.

So I would just have to add an Animator and switch that out with Humanoid and load the animation on that one and then play it?

Mayb it will solve the issue. ignore

I switched it out. Still nothing happends.

local humanoid = c.Humanoid	
local anim = humanoid.Animator:LoadAnimation(script:FindFirstChildOfClass("Animation"))

anim:Play()
print(script:FindFirstChildOfClass("Animation")

image
image

Then why not do

script:FindFirstChild("Animation")

Also is the character var nil?

The character is not nil. “ignore this”

Also FYI, make sure u own the animations, otherwise it won’t run.

It looks like it didnt save correctly, Ill be back in a bit.

It works now i redid the animation with the roblox animator