I'm a beginner scripter I created this script for my ai that finds closest player but it doesn't follow the players
local PathfindingService = game:GetService("PathfindingService") local robot = script.Parent local humanoid = robot.Humanoid local maks = 500 function gtp() local cp = robot.HumanoidRootPart.Position local p = game.Players:GetChildren() for i,v in pairs(p) do local pos = p.Character.HumanoidRootPart.Position local mpos = math.min(cp-pos) if mpos <= maks then local path = PathfindingService:CreatePath() path:ComputeAsync(cp,pos) local waypoints = path:GetWaypoints() for _,waypoint in pairs(waypoints) do humanoid:MoveTo(waypoint) humanoid.MoveToFinished:Wait() end break end end end