Making an NPC/Part teleport in a random position near a player

How would I be able to make a part/npc teleport in a random position NEAR the player, WITHOUT teleporting into any obstacles (for example: trees, walls, etc).

Code samples or an explanation would be much appreciated.

Here’s 2 images for a better understanding of what I am trying to achieve.


1 Like

Found a way to do this, you need to use Random.new(), specifically NextUnitVector and of course, raycasting.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.