Go to the BP_SmartAIComponent and create a new variable called SpawnedBy and set its type to Actor.

Create another variable called AllowDynamicRespawnCheck and set its type to Boolean.

Then create a new function called Despawn Check then copy the images below.

Add the highlighted nodes shown in the image below, location at the top of the image.