so basicly heres the justs of it.. the zombie starts out with a big sphere outside of it. you touch it and the zombie comes after you. and then you can either kill it or run away from it and then it will stoping chasing you. but the error happens when it starts chasing you and then it stops chasing you it brings up a error and i have been stuck on it for about 2 hours now and i still cant figure it out. here is the main script and the module script..
local zombie = script.Parent
local humanoid = zombie.Humanoid
local hrp = zombie.HumanoidRootPart
local za = require(script.ZombieMovement) -- this is the small zombie API i made
function start()
local s = za.makesphere(hrp.Position)
s.Touched:Connect(function(hit)
if hit.Name == "UpperTorso" then
s:Destroy()
print("go")
print(hit.Parent)
za.trackplayer(hit.Parent)
end
end)
end
start()
and the mod script
local m = {}
function movethezombie(player) --moves the zombie to the players position
local pfs = game:GetService("PathfindingService"):ComputeRawPathAsync(script.Parent.Parent.HumanoidRootPart.Position,player.HumanoidRootPart.Position,500)
local path = pfs:GetPointCoordinates()
script.Parent.Parent.Humanoid.WalkToPoint = path[2]
end
function m.trackplayer(player) -- trakcs on to the player
local zh = script.Parent.Parent.Humanoid
local hrp = script.Parent.Parent.HumanoidRootPart
print("Started")
while((player.HumanoidRootPart.Position - hrp.Position).magnitude < 45) do -- this little part right here basicly (in theory) will make the zombie stop
end -- tracking you if you are at a certain range from it
return
end
function m.makesphere(pos) -- this sphere will spawn around the zombie and will start chasing you if you touch it
local a = Instance.new("Part",workspace)
a.Size = Vector3.new(25,25,25)
a.CanCollide = false
a.Position = pos
a.Shape = Enum.PartType.Ball
a.Anchored = true
return a
end
return m
