I have tried several scripts to put the animation controller inside of the model including local and regular scripts. No matter what i do, the npc does not play the animation i made using the animation editor, yes i have a humanoidrootpart, a head, and a torso. Please help, i need to figure this out in order to continue the game im making. Im not asking for a full script, i just need to know what im doing wrong, ill post the script im using if needed. Thanks in advanced
✓ ANSWER ACCEPTED
How to animate a custom npc?
2 answers
✓ Accepted answer
Greetings , i'll probably need you to post a few pictures of how you're setting the humanoid up , i'll also need the script , but before doing so , try getting this in the Humanoid/Model (You need an Animation controller just if it's not an humanoid , i believe you can just load the animation in the humanoid directly)
function onTouched(Part)
if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= script.Parent.Name then
local Torso = script.Parent:WaitForChild("Torso")
local Anim = game.ReplicatedStorage.Animations:WaitForChild("YourAnimation") -- This is just an example , i don't know where you have your anim.
local Human = script.Parent:FindFirstChild("Humanoid")
local YourAnimation = Human:LoadAnimation(Anim)
YourAnimation:Play()
end
Torso.Touched:connect(onTouched) -- This script would play any animation once you've touched the torso of your npc.
3 comments
0
THANK YOU THAT WORKED!!
0
Pm me if you need something else , it may be faster.
0
Alright thanks man!
while wait() do
local Torso = script.Parent:WaitForChild("Torso") --Wait for the torso
local Anim = game.Workspace.Animations:WaitForChild("Anim") --Path to your animation
local Human = script.Parent:FindFirstChild("Humanoid") --Wait for the humanoid
local YourAnimation = Human:LoadAnimation(Anim) --Load the animation into the humanoid
YourAnimation:Play() --Play the animation
wait(3) --Wait 3 seconds
end
In case someone stumbles upon this in the future and doesnt understand. This will constantly loop your animation just to test it, if you dont want it to loop, just remove the while wait() do. A big thank you to Fabiox99 for supplying the answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Do you have a umanoid?
Yea