Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local e = script.Parent:FindFirstChild("Body Colors")
- if e then
- e:Destroy()
- end
- script.Name = "Zombie"
- local animation_attack = Instance.new("Animation")
- animation_attack.AnimationId = "http://www.roblox.com/asset/?id=362957401"
- local running_animation_attack = nil
- Character = script.Parent
- Humanoid = Character.Humanoid
- Torso = Character["Torso"]
- Head = Character["Head"]
- RightArm = Character["Right Arm"]
- LeftArm = Character["Left Arm"]
- RightLeg = Character["Right Leg"]
- LeftLeg = Character["Left Leg"]
- Head.BrickColor = BrickColor.new("Slime green")
- RightArm.BrickColor = BrickColor.new("Slime green")
- LeftArm.BrickColor = BrickColor.new("Slime green")
- LeftLeg.BrickColor = BrickColor.new("Slime green")
- RightLeg.BrickColor = BrickColor.new("Slime green")
- Torso.BrickColor = BrickColor.new("Slime green")
- Humanoid.DisplayDistanceType = "None"
- wait(1)
- Head.BrickColor = BrickColor.new("Slime green")
- RightArm.BrickColor = BrickColor.new("Slime green")
- LeftArm.BrickColor = BrickColor.new("Slime green")
- LeftLeg.BrickColor = BrickColor.new("Slime green")
- RightLeg.BrickColor = BrickColor.new("Slime green")
- Torso.BrickColor = BrickColor.new("Slime green")
- Humanoid.MaxHealth = "inf"
- Humanoid.Health = "inf"
- Humanoid.WalkSpeed = 17
- local BITE = {"131138828","131138835","131138832"}
- function CreateSound(ID, PARENT, VOLUME, PITCH)
- coroutine.resume(coroutine.create(function()
- local NEWSOUND = Instance.new("Sound", PARENT)
- NEWSOUND.Volume = VOLUME
- NEWSOUND.Pitch = PITCH
- NEWSOUND.SoundId = "http://www.roblox.com/asset/?id="..ID
- NEWSOUND:play()
- game:GetService("Debris"):AddItem(NEWSOUND, 10)
- end))
- end
- MRANDOM = math.random
- attack = false
- function onTouch(part)
- Head.BrickColor = BrickColor.new("Slime green")
- RightArm.BrickColor = BrickColor.new("Slime green")
- LeftArm.BrickColor = BrickColor.new("Slime green")
- LeftLeg.BrickColor = BrickColor.new("Slime green")
- RightLeg.BrickColor = BrickColor.new("Slime green")
- Torso.BrickColor = BrickColor.new("Slime green")
- local humanoid = part.Parent:FindFirstChild("Humanoid")
- if (humanoid ~= nil) and attack == false and part.Parent:FindFirstChild("Zombie") == nil and part.Parent:FindFirstChild("AIEntity") == nil then
- attack = true
- game:GetService("ContentProvider"):Preload(animation_attack.AnimationId)
- if(running_animation_attack == nil) then
- local event_keyframe_reached
- running_animation_attack = Humanoid:LoadAnimation(animation_attack)
- running_animation_attack:Play()
- if humanoid.Health > 1000 then
- humanoid.MaxHealth = 100
- humanoid.Health = 100
- end
- CreateSound(BITE[MRANDOM(1, #BITE)], Head, 4, MRANDOM(8, 12) / 10)
- CreateSound("201858024", part, 2, math.random(8, 12) / 10)
- humanoid.Health = humanoid.Health - 50
- if humanoid.Health < 30 then
- humanoid.MaxHealth = "inf"
- humanoid.Health = "inf"
- local zombie = humanoid.Parent:Clone()
- zombie.Parent = workspace
- zombie.Torso.CFrame = humanoid.Parent.Torso.CFrame
- humanoid.Parent:Destroy()
- local sc = script:Clone()
- sc.Parent = zombie
- local identity = Instance.new("Folder")
- identity.Parent = zombie
- identity.Name = "AIEntity"
- zombie.Name = "Zombie"
- end
- wait(0.3)
- running_animation_attack:Stop()
- running_animation_attack = nil
- attack = false
- end
- end
- end
- function findNearestTorso(pos)
- local list = game.Workspace:children()
- local torso = nil
- local dist = 1000
- local temp = nil
- local human = nil
- local temp2 = nil
- for x = 1, #list do
- temp2 = list[x]
- if (temp2.className == "Model") and (temp2 ~= script.Parent) and temp2:FindFirstChild("Zombie") == nil then
- temp = temp2:findFirstChild("Torso")
- human = temp2:findFirstChild("Humanoid")
- if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
- if (temp.Position - pos).magnitude < dist then
- torso = temp
- dist = (temp.Position - pos).magnitude
- end
- end
- end
- end
- return torso
- end
- RightArm.Touched:connect(onTouch)
- LeftArm.Touched:connect(onTouch)
- Torso.Touched:connect(onTouch)
- RightLeg.Touched:connect(onTouch)
- LeftLeg.Touched:connect(onTouch)
- while true and script.Parent:FindFirstChild("AIEntity") do
- wait(math.random(1,5))
- local target = findNearestTorso(script.Parent.Torso.Position)
- if target ~= nil then
- script.Parent.Humanoid:MoveTo(target.Position, target)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement