Whenever I try to load an animation into an NPC, it says "Object must be in Workspace before loading animation."This is the script( which is in the npc model)
hitt = false
function Hit(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if not hitt and hit.Parent.Name ~= script.Parent.Name and script.Parent:FindFirstChild("Left Arm") and script.Parent:FindFirstChild("Right Arm") and human and hit.Parent:FindFirstChild("IsSoldier") and hit.Parent.IsSoldier.Value == true then
hitt = true
local AnimController = Instance.new("AnimationController",script.Parent)
local animation = Instance.new("Animation",script.Parent.Humanoid)
animation.AnimationId = "http://www.roblox.com/asset?ID=359602146"
local animTrack = AnimController:LoadAnimation(animation)
animTrack:Play() -- play animation
human:TakeDamage(math.random(20,30))
wait(.8)
animation:Destroy()
AnimController:Destroy()
hitt = false
end
end
script.Parent["Left Arm"].Touched:connect(Hit)
script.Parent["Right Arm"].Touched:connect(Hit)
As you can see, the animation is created in the script and placed into the humanoid. P.S. The model usually attacks someone(using this script) shortly after it is cloned from the serverstorage to the workspace(about 1 second)

1 comment
Thanks! I figured out that there was no humanoidrootpart, thanks anyways!