I was making a script and on line 6 it all ways gives the error attempt to index a number value
local PathfindingService = game:GetService("PathfindingService") local char = script.Parent local Humanoid = char.Humanoid while true do local path = PathfindingService:CreatePath() path:ComputeAsync(char.HumanoidRootPart.Position, Vector3.new(char.PrimaryPart.Position.X + math.random(-10,10),char.PrimaryPart.Position.Y + math.random(-10,10),char.PrimaryPart.Position.X + math.random(-10,10).Z)) -- the errors here path.Blocked:Connect(function() path:ComputeAsync(char.HumanoidRootPart.Position, Vector3.new(char.PrimaryPart.Position.X + math.random(-10,10),char.PrimaryPart.Position.Y + math.random(-10,10),char.PrimaryPart.Position.X + math.random(-10,10).Z)) end) local waypoints = path:GetWaypoints() for _, waypoint in pairs(waypoints) do char:MoveTo(waypoint.Position) Humanoid.MoveToFinished:Wait() end wait(1) end
I'm not sure about that specific error, but
char.PrimaryPart.Position.X + math.random(-10,10).Z
looks strange. Math.random doesn't have a Z property