function Path.new(R,k)if not(R and(R:IsA("\077\111\100\101\108")and R.PrimaryPart))then output(error,"\080\097\116\104\102\105\110\100\105\110\103 \097\103\101\110\116 \109\117\115\116 \098\101 \097 \118\097\108\105\100 \077\111\100\101\108 \073\110\115\116\097\110\099\101 \119\105\116\104 \097 \115\101\116 \080\114\105\109\097\114\121\080\097\114\116\046")end local t=setmetatable({_events={Reached=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116");WaypointReached=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116"),Blocked=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116"),Error=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116"),Stopped=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")},_agent=R;_humanoid=R:FindFirstChildOfClass("\072\117\109\097\110\111\105\100");_path=PathfindingService:CreatePath(k);_status="\073\100\108\101",_t=0,_position={_last=Vector3.new();_count=0}},Path)t._path.Blocked:Connect(function(...)if(t._currentWaypoint<=...and t._currentWaypoint+1>=...)and t._humanoid then setJumpState(t)t._events.Blocked:Fire(t._agent,t._waypoints[...])end end)return t end
--
function Path.new(agent, agentParameters)
	if not (agent and agent:IsA("Model") and agent.PrimaryPart) then
		output(error, "Pathfinding agent must be a valid Model Instance with a set PrimaryPart.")
	end
	
	local self = setmetatable({
		_events = {
			Reached = Instance.new("BindableEvent");
			WaypointReached = Instance.new("BindableEvent");
			Blocked = Instance.new("BindableEvent");
			Error = Instance.new("BindableEvent");
			Stopped = Instance.new("BindableEvent");
		};
		_agent = agent;
		_humanoid = agent:FindFirstChildOfClass("Humanoid");
		_path = PathfindingService:CreatePath(agentParameters);
		_status = "Idle";
		_t = 0;
		_position = {
			_last = Vector3.new();
			_count = 0;
		};
	}, Path)
	
	--Path blocked connection
	self._path.Blocked:Connect(function(...)
		if (self._currentWaypoint <= ... and self._currentWaypoint + 1 >= ...) and self._humanoid then
			setJumpState(self)
			self._events.Blocked:Fire(self._agent, self._waypoints[...])
		end
	end)
	
	return self
end

