This is a very simple AI detection script which has an invisible "visibility range" that said entity has. Feel free to mess around with the visibility range and remix the project.
Though instead I could have used a variable instead of a list, the list made it optimal so that you can have multiple visibility ranges at once.