Untitled
unknown
plain_text
10 days ago
1.2 kB
4
Indexable
local npc = script.Parent local humanoid = npc:FindFirstChild("Humanoid") local rootPart = npc:FindFirstChild("HumanoidRootPart") local pathfindingService = game:GetService("PathfindingService") function moveToPosition(destination) if humanoid and rootPart then local path = pathfindingService:CreatePath({ AgentRadius = 2, -- Ajusta según el tamaño del NPC AgentHeight = 4, AgentCanJump = false, -- No queremos que salte si es de 4 patas AgentCanClimb = false }) path:ComputeAsync(rootPart.Position, destination.Position) if path.Status == Enum.PathStatus.Success then local waypoints = path:GetWaypoints() for _, waypoint in pairs(waypoints) do humanoid:MoveTo(waypoint.Position) humanoid.MoveToFinished:Wait() end end end end while true do -- Busca un punto aleatorio en un radio de 50 studs local randomPosition = rootPart.Position + Vector3.new(math.random(-50,50), 0, math.random(-50,50)) moveToPosition({Position = randomPosition}) wait(3) -- Espera 3 segundos antes de moverse de nuevo end
Editor is loading...
Leave a Comment