[This is a Server Script in the NPC] Here is a animation a buddy of mine is working on and it is not loading the animation. I am not sure what is going on. The NPC walks but it does not get the animation. There are no errors.

local zombie = script.Parent
local target = nil

local walkAnimation = Instance.new("Animation")
walkAnimation.AnimationId = "http://www.roblox.com/asset/?id=477950987"

local animationController = Instance.new("AnimationController", zombie)

local walk = animationController:LoadAnimation(walkAnimation)

function findClosestPlr()
	local pos1 = zombie.Torso.Position
	local closest = nil
	local closestDistance
	for _, plr in pairs(game.Players:GetPlayers()) do
		local pos2 = plr.Character.Torso.Position
		local distance = (pos1 - pos2).magnitude
		if not closest or distance < closest then
			closest = plr
			closestDistance = distance
		end
	end
	target = closest
	return closestDistance
end

function walkToPlr()
	zombie.Humanoid.WalkToPoint = target.Character.Torso.Position
	if #animationController:GetPlayingAnimationTracks() == 0 then
		walk:Play()
	end
end

while wait() do
	if findClosestPlr() <= 200 then
		walkToPlr()
	end
end

3 comments

0

Most likely the rig is not set up for animations properly.

0

Roblox broke and still hasn't fixed AnimationController, I get this issue all the time along with alot of other ppl. You might have to Clerp the animation.

0

What u mean by Clerp?