Self returning nil on the module functions that are being used inside other module functions

function AI:CreatePath(Destination : Vector3)
    local NewDestination =     self.CurrentPatrolPoint or Destination
    local AgentParams = {
        ["AgentRadius"] = self.AgenRadius,
        ["AgentHeight"] = self.AgentHeight,
        ["AgentCanJump"] = self.AgentCanJump
    }
    
    self.CurrentPatrolPoint = NewDestination
    
    local Path = PathFindingService:CreatePath(AgentParams)
    print("Printing here: "..self.RootPart.Name)
    Path:ComputeAsync(self.RootPart.Position,Destination)

    return Path
end

function AI:CanSeeTarget(target)    
    local RayCastParams = RaycastParams.new()
    RayCastParams.FilterDescendantsInstances = {self.Model}
    RayCastParams.FilterType = Enum.RaycastFilterType.Exclude    
    local Orgin = self.RootPart.Position
    local Direction = (target.RootPart.Position - self.RootPart.Position).Unit
    
    local raycastResult = workspace:Raycast(Orgin, Direction * self.SightDistance, RayCastParams)

    if raycastResult and raycastResult.Instance then
        if raycastResult.Instance:IsDescendantOf(target) then
            return true
        else
            return false
        end
    else
        return false
    end
end

function AI:MoveToPath (NewPath: Path)
    
    local Waypoints = NewPath:GetWaypoints()
    
    print(self.RootPart)
    print(self.Model)
    print(self.MaxChaseDistance)
    
end

This is my module Script

-- AI Module --
local AI_NPC = AI_Module.InnitAICharacter(NPC,WaypointsFolder,SFXFolder,script)

Humanoid.Died:Connect(function()
    AI_NPC:ChangeState(AI_NPC.States.Dead)
end)

while task.wait(0.3) do
    local Waypoint = AI_NPC:GetRandownWayPoint()
    local Path = AI_NPC:CreatePath(Waypoint.Position)
    AI_NPC:MoveToPath(Path)
end

This is my Server Script

In the Module Function, MoveToPath as well as CreatePath , i can get the self variables set but when i tried to access an element inside the self table on CanSeeTarget , so here RootPart is nil while its returning the RootPart object in MoveToPath as well as create path

An instance can become nil if there is a wait between acesses, if it the instance has actually be removed in that time. It can also be nil if it is passed from client to server or back, and doesn’t exist on the receiving side. This can be caused by StreamingEnabled, or by client/server only instances.

Actually i don’t know how there is a wait inside here, since it happens only when i use the module function inside a module function.