Animations not working

After fully coding my zombie module script, an issue has arose. The zombie’s animations have completely broke. Walking, the zombie attack animation and etc. I’ve tried to re-insert the code into a new character including the player and a new rig but nothing has seemed to work. This is an example of the animation breaking:


Here’s the script:

l

ocal ai = {}
local renderservice = game:GetService("RunService")
function ai.Follow(plr, humrootpart)
	local hum = script.Parent.Zombie
	local hitbox = script.Parent.HitBox
   local animator = hum.Animator
	local animid_kill = script.ZombieAttack
	local distance = nil
	local direction = nil
	local zombieroot = script.Parent.HumanoidRootPart
	local debounce = false
	local Conn = renderservice.Heartbeat:Connect(function()
		local mag = (humrootpart.Position - zombieroot.Position)
	distance = mag.Magnitude
		direction = mag.Unit
		hitbox.Touched:	Once(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				if debounce == false then
				debounce = true
					hit.Parent.Humanoid:TakeDamage(5)
					animator:LoadAnimation(animid_kill):Play()
				print("works!")
				task.wait(2)
				debounce = false
				end
				end
		end)
	if distance <=100 then
			hum:Move(direction)
		end
	end)

	plr.Character.Humanoid.Died:Once(function()
		Conn:Disconnect()
	end)
end

return ai
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local module = require(script.Parent.ZombieScript)
		module.Follow(plr, char.HumanoidRootPart)
	end)

end)

A solution I’ve tried is to remove the kill animation entirely but to no avail.

Do you own the animation? Did you set the animation priorities correctly?

hey can you show the npc humanoid, its pretty sure because it has no animator

The humanoid does have an animator otherwise the script would error and not work entirely

I’ll look into the animation priorities.

maybe try this?

ocal ai = {}
local renderservice = game:GetService("RunService")
function ai.Follow(plr, humrootpart)
	local hum = script.Parent.Zombie
	local hitbox = script.Parent.HitBox
   local animator = hum.Animator
	local animid_kill = script.ZombieAttack
    local animid_killgo = hum:LoadAnimation(animid_kill)
	local distance = nil
	local direction = nil
	local zombieroot = script.Parent.HumanoidRootPart
	local debounce = false
	local Conn = renderservice.Heartbeat:Connect(function()
		local mag = (humrootpart.Position - zombieroot.Position)
	distance = mag.Magnitude
		direction = mag.Unit
		hitbox.Touched:	Once(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				if debounce == false then
				debounce = true
					hit.Parent.Humanoid:TakeDamage(5)
					animid_killgo:Play()
				print("works!")
				task.wait(2)
				debounce = false
				end
				end
		end)
	if distance <=100 then
			hum:Move(direction)
		end
	end)

	plr.Character.Humanoid.Died:Once(function()
		Conn:Disconnect()
	end)
end

return ai

I changed the animation priority of the zombie attack but it still does not work.

does output say anything though

The output doesn’t say anything and the solution you gave still does not fix the animation.

ill check out your code on my npc. i might say whats wrong.

1 Like

wait arent you missing out the “L” in the very start?

I added the L back when I pasted your script and even if I didn’t I would probably notice the error

i see no issue your script works. maybe its because ur not the owner of the game

But the problem is I am the owner
Maybe my game is bugged

module inside zombie

local ai = {}
local renderservice = game:GetService("RunService")
function ai.Follow(plr, humrootpart)
	local hum = script.Parent.Zombie
	local hitbox = script.Parent.PrimaryPart
	local animator = hum.Animator
	local animid_kill = script.ZombieAttack
	local distance = nil
	local direction = nil
	local zombieroot = script.Parent.HumanoidRootPart
	local debounce = false
	local Conn = renderservice.Heartbeat:Connect(function()
		local mag = (humrootpart.Position - zombieroot.Position)
		distance = mag.Magnitude
		direction = mag.Unit
		hitbox.Touched:	Once(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				if debounce == false then
					debounce = true
					hit.Parent.Humanoid:TakeDamage(5)
					animator:LoadAnimation(animid_kill):Play()
					print("works!")
					task.wait(2)
					debounce = false
				end
			end
		end)
		if distance <=100 then
			hum:Move(direction)
		end
	end)

	plr.Character.Humanoid.Died:Once(function()
		Conn:Disconnect()
	end)
end

return ai

script inside module

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local module = require(script.Parent)
		module.Follow(plr, char.HumanoidRootPart)
	end)

end)

can you send the zombie anim, its either because of priority or some other bugs.
edit: i found the issue in the anim.

It’s the same as the default Roblox animation
And yes the script works, it’s just the animation

em
your anim prob doesnt work because of that,

change the anim id to
3101922409

Changed the animation id of the walk and run animation but to no avail. I am baffled

try making a short swing r15 anim with your rig and make the swing use it, USE roblox animation editor.