When the script is supposed to make a circle around the creature it makes it in the center of the map:
while wait() do
local angle = math.random(0,2*math.pi)-- Random angle in radians
local x, y, z = math.cos(angle ) * radius , character.PrimaryPart.Position.Y, math.sin(angle) * radius -- end poistion
local humanoid = character.Humanoid --- ur humanoid
for i,v in pairs(PathParts) do
v:Destroy()
end
if findNearestTorso(character.PrimaryPart.Position) then
if script.Circle.Value == true then
followPathCircle(script.Parent, Vector3.new(x,y,z))
isReturned = false
oldtime = tick()
else
followPath(character, findNearestTorso(character.PrimaryPart.Position).Position)
isReturned = false
oldtime = tick()
end
end
end
Its the followPathCircle
local function followPathCircle(character, destination)
local humanoid = character.Humanoid
-- Compute the path
local success, errorMessage = pcall(function()
path:ComputeAsync(character.PrimaryPart.Position, destination)
end)
if success and path.Status == Enum.PathStatus.Success then
-- Get the path waypoints
waypoints = path:GetWaypoints()
local distance = (character.PrimaryPart.Position - waypoints[#waypoints].Position).Magnitude
arrival = (distance/humanoid.WalkSpeed) + stayTime
for i,waypoint in pairs(waypoints) do
drawCircle(waypoint) -- DELETE IF YOU WANT THE PATH TO NOT SHOW
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:wait()
end
end
end