zombieHumanoid = script.Parent.Humanoid
script.Parent.Torso.Touched:Connect(function(otherPart: BasePart)
if game.Players:GetPlayerFromCharacter(otherPart.Parent)~=nil then
local speed = zombieHumanoid.WalkSpeed
local anims = script.Parent.Animations.AttackAnims:GetChildren()
if #anims == 0 then return end -- No animations to play
local anim = anims[math.random(1,#anims)]
local animator = zombieHumanoid:FindFirstChildOfClass("Animator")
if not animator then return end -- No animator
zombieHumanoid.WalkSpeed=0
local track = zombieHumanoid:LoadAnimation(anim) -- Use zombieHumanoid and its Animator
track:Play()
zombieHumanoid.WalkSpeed=20
end
end)
Whenever a zombie attacks a player, it just stops, and won’t move at all after that. Note: The zombie uses the standard Drooling Zombie AI, although the damage code is modified to this:
local healths = {
"LeftArm",
"RightArm",
"LeftLeg",
"RightLeg",
"Head",
"Torso",
}
local zombie = script.Parent
damage = math.random(35,50)
function LoadSound(path,location)
local sounds = script.Sounds:FindFirstChild(path)
if sounds==nil then return nil end
local soundslist = sounds:GetChildren()
local sound = soundslist[math.random(1,#soundslist)]
if not sound:IsA("Sound") then return nil end
local audio = sound:Clone(location)
audio.PlaybackSpeed=math.random(80,120)/100
audio.Volume=math.random(40,75)/100
audio.RollOffMinDistance=math.random(5,15)
audio.RollOffMaxDistance=math.random(30,50)
audio:Play()
game.Debris:AddItem(audio,audio.TimeLength*audio.PlaybackSpeed)
end
db=false
script.Parent.Torso.Touched:Connect(function(otherPart: BasePart)
local zombieHumanoid = script.Parent.Humanoid
local zombieRootPart = script.Parent.HumanoidRootPart
local char = otherPart.Parent
local medical = char:FindFirstChild("Medical")
if medical~=nil and db==false and char.Name~="Drooling Zombie" and zombieHumanoid and zombieHumanoid.Health > 0 then
local health = healths[math.random(1,#healths)]
local hp = medical:FindFirstChild(health.."Health")
local head = char:FindFirstChild("Head")
if hp~=nil then
hp.Value=hp.Value-(damage*(math.random(75,150)/100))
end
local injury=medical:FindFirstChild(health.."Injury")
if injury~=nil then
if injury.Value=="None" then
if math.random(1,8)==1 then
if math.random(1,5)==1 then
injury.Value="InfectedBite"
else
injury.Value="Bite"
end
if head~=nil then LoadSound("Bite",head) end
elseif math.random(1,4)==1 then
if math.random(1,3)==1 then
injury.Value="MajorBruise"
else
injury.Value="MinorBruise"
end
if head~=nil then LoadSound("Bruise",head) end
else
if math.random(1,5)==1 then
injury.Value="InfectedScratch"
else
injury.Value="Scratch"
end
if head~=nil then LoadSound("Scratch",head) end
end
end
end
db=true
local hum = char:FindFirstChildOfClass("Humanoid")
if hum~=nil then
if math.random(1,math.round(hum.Health/8))==1 then
hum.Sit=true
end
end
task.wait(0.5)
db=false
else
end
end)
Note that the damage code and animation code are in separate scripts. The Arms animation in the default drooling zombie model is disabled as well.