How do i let an npc spawn on a random location

hello everyone
i am making an npc fighting game and i want npc to spawn in a random location but not on the entire map could someone maybe help me with that i dont have a code yet so i cant post it here

  1. i want help of someone with experience in coding that might be able to help me
  2. i want the npc to respawn somewere random on the map after a certain amount of time
  3. i looked this up and i found multiple thing but the scripts were just broken and i did not understand it so if u would send me a code please tel how it works so i can learn to script better

You could use math.random() on each coordinate of a Vector3 to define a random spawn point within a certain area.

The problem with math.random is that it can return the same values when called frequently.

What I would do is have a table containing possible spawn locations and just get a random index of that table. This way you can prevent duplicate spawn positions.

Add a few parts around the map, these will be the respawn locations. Do a math.random(), and spawn the NPC on a random part.