RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"its gouge forwards and backwards and all sorts of directions"
-- server script local pfs = game:GetService("PathfindingService") local pug = game.Workspace.Pug -- Assuming the model is in Workspace local humanoid = pug:FindFirstChildWhichIsA('Humanoid') if not humanoid then humanoid = Instance.new('Humanoid') humanoid.Parent = pug end local function getRandomPoint() local x = math.random(-50, 50) -- Adjust these values to fit your baseplate size local z = math.random(-50, 50) return Vector3.new(x, 0, z) end while true do local destination = getRandomPoint() local path = pfs:CreatePath() path:ComputeAsync(pug.HumanoidRootPart.Position, destination) local waypoints = path:GetWaypoints() for i, waypoint in ipairs(waypoints) do humanoid:MoveTo(waypoint.Position) humanoid.MoveToFinished:Wait() end task.wait(5) -- Wait for 5 seconds before moving to next random point -- Reverse direction local reversePath = pfs:CreatePath() reversePath:ComputeAsync(pug.HumanoidRootPart.Position, -destination) local reverseWaypoints = reversePath:GetWaypoints() for i, waypoint in ipairs(reverseWaypoints) do humanoid:MoveTo(waypoint.Position) humanoid.MoveToFinished:Wait() end task.wait(5) -- Wait for 5 seconds before moving to next random point end