Hello there! I want to make monster that will found you in any location.
I made this script:
plr = workspace:WaitForChild('pupersuperkirill')
pathf = game:GetService("PathfindingService")
pathf = game:GetService("PathfindingService")
function l(n1,n2)
if (n1.Position - n2.Position).magnitude > 2.5 then
return true
end
end
function getpoint(points)
for q,i in pairs(points) do
if points[q+1] and points[q+2] and l(points[q],points[q+1]) then
point = points[q+1]
return point
end
end
return points[2]
end
while true do
path = pathf:CreatePath{
AgentRadius = script.Parent:GetExtentsSize().X-1.5,
AgentHeight = script.Parent:GetExtentsSize().Y-1.5,
AgentCanJump = true,
WaypointSpacing = 2.5
--Costs = {
-- Grass = 10
--}
}
path:ComputeAsync(script.Parent.PrimaryPart.Position,plr.PrimaryPart.Position)
points = path:GetWaypoints()
--for _, i in pairs(points) do
point = getpoint(points)
--if (point[1].Position - points[2].Position).magnitude < 2 then
-- point = points[3]
--end
if point then
if point.Action == Enum.PathWaypointAction.Jump and script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
pos = point.Position
script.Parent.Humanoid:MoveTo(pos)
end
--end
end
But npc sometimes stucks,goes with little stops.
Do you have any script or recomendation how to make a clever monster like piggy,scp 3008 A in scp 3008?