Okay, so I want my Zombie to follow other players and to kill them. I attempted to make a Script for the Zombie following people but it did not work. I also did not know how to allow the zombie to kill people. Here is my script.
local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm") distance = script.Parent.Configuration.distance.Value
function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = distance 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(math.random(1,1)) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Humanoid:MoveTo(target.Position, target) end
end