How can I make/script a zombie?
Zombies have been popular in ROBLOX games for at least seven years. The first game I can remember featuring zombies was by Servano, and their workings are very simple and basic.
Humanoid:MoveTo(Vector3 location, Part part) causes the character of the humanoid to walk to the location.
The classic zombie searches for the nearest character's torso in a while loop and then follows it with Humanoid:MoveTo(Torso.Position, Torso).
You could try something like this for the scripting:
fdistance = 40 --how close you want them to be before following zombie = script['Parent'] while wait() do local closestp = nil; local closestdist = fdistance; for i,v in pairs (game['Players']:GetChildren()) if (v.Character.Torso.Position-zombie.Torso.Position).magnitude <= closestdist then closestp = v closestdist = (v.Character.Torso.Position-zombie.Torso.Position).magnitude end end zombie.Humanoid:MoveTo(closestp.Character.Torso.Position, closestp.Character.Torso) end
Might not work. I just came up with it, and haven't tested it. Requires the zombie to have a torso named "Torso", and a Humanoid named "Humanoid"
1.Make 4 bricks Named: -Head -Torso -Right Leg -Left Leg
1.5.you can also add arms but you dont have to, the zombie will work fine without them
2.Put them together in any way but: Head must be connected to Torso Right Leg must be connected to Torso Left Leg must be connected to Torso
3.The Shape of the Parts does not matter at all
4.Group all the Parts together in a model and add the scripts below IN THE MODEL
5.IMPORTENT: Also add a Humanoid in the model and re-name it to Humanoida so the scripts work
6.RESPAWN
name="Humanoida"
robo=script.Parent:clone()
while true do wait(5) if script.Parent.Humanoida.Health<1 then robot=robo:clone() robot.Parent=script.Parent.Parent robot:makeJoints() script.Parent:remove() end end
7.FOLLOW SCRIPT
local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm")
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) then temp = temp2:findFirstChild("Right Arm") 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
while true do wait(0.5) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Humanoida:MoveTo(target.Position, target) end
end
8.HEALTH REGENERATION
function waitForChild(parent, childName) while true do local child = parent:findFirstChild(childName) if child then return child end parent.ChildAdded:wait() end end
local Figure = script.Parent local Head = waitForChild(Figure, "Head") local Humanoid = waitForChild(Figure, "Humanoida") Humanoid.Health=250
while true do local s = wait(4) local health = Humanoida.Health if health > 0 and health < Humanoid.MaxHealth then health = health + 0.08 * s * Humanoid.MaxHealth if health * 1.05 < Humanoid.MaxHealth then Humanoid.Health = health else Humanoid.Health = Humanoid.MaxHealth end end end
9.HURT/KILL
function onTouch(part) local h = part.Parent:FindFirstChild("Humanoid") if (h ~= nil) then h.Health = h.Health -10 end end
script.Parent.Touched:connect(onTouch)
9.5.If you want the Zombie to kill you instantly copy:
function onTouch(part) local h = part.Parent:FindFirstChild("Humanoid") if (h ~= nil) then h.Health = 0 end end
script.Parent.Touched:connect(onTouch)
10.Add Hurt/Kill to all body parts of the zombie or just the arms so only the arms kill you
12.Check the settings in the Humanoida to make sure that the legs, Torso, and Head are accounted for
13.Dont change anything in the scripts unless you know what your doing!
Hope i helped!