The script has changed every time I've tried everything. First I tried to get players from in pairs, then have it choose a random player and move towards the picked player humanoid root part but that wouldn't work. Now I am attempting to create a sight hitbox so if a player is within it then it will move towards the player. The issue I'm having is that it is saying "MoveTo is not a valid member of Part "Workspace.Zombie.HumanoidRootPart". " the damage one is working.
local zombie = script.Parent
local humanoid = zombie.HumanoidRootPart
local hitbox = zombie:WaitForChild("HitBox")
local damage = zombie.Configuration.damage.Value
hitbox.Touched:Connect(function(hit)
if hit.Parent then
local human = hit.Parent:FindFirstChild("Humanoid")
if human and hit.Parent.Name ~= "Zombie" then
human.Health = human.Health - damage
end
if hit.Name == "Bullet" then
humanoid.Health = humanoid.Health - hit.Parent:FindFirstChild("Damage").Value
hit:Destroy()
if humanoid.Health <= 0 then
zombie:Destroy()
end
end
end
end)
-- end of damage script everything above works
-- start movement
local sight = zombie.sight -- 2nd hitbox for movement
sight.Touched:Connect(function(hit)
local charr = hit.Parent:FindFirstChild("Humanoid")
local char = hit.Parent:FindFirstChild("HumanoidRootPart")
if charr and hit.Parent.Name ~= ("Zombie") then
humanoid:MoveTo(char.Position)
end
end)

1 comment
Had to define the primary part of model, but it isn't making the zombie walk, just teleporting it into the player.