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.
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
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)