Performance of .Touched vs :FindPartsInRegion3

Hi all, sorry if this is in the wrong category I wasn’t sure whether to post here or in code review.

Currently, I am working on a large fantasy/JRPG game. I am trying to emulate the experience of grinding by fighting loads of repetitive(ish) monsters, while maintaining large server sizes. I’m currently trying to optimize the enemy handling script, by spawning enemies in and out depending on whether players are in close proximity/are in the specified zones.

Each breed of monster is assigned to a zone, and a zone is represented by a large region3 accessible through a module script. I need to figure out whether there are players in the region3 or not. Would it be more performant to set up a .Touched/.TouchEnded events, plus some kind of already picked up list kinda thing, or to use :FindPartsInRegion3WithWhiteList, plus a list of a player parts, every few seconds?

Also, any tips on how to handle a few hundred NPCs would be much appreciated. Currently, I’m disabling all states, handling anims on the client, tweening on the server (rather than using Humanoid:MoveTo), I’m parenting any far, far away NPCs to ServerStorage, and I’m only running code for those in the Workspace.

Thanks for reading :slight_smile:

I would use FindPartsInRegion since anytime your about to spawn a monster you can check if somebody is inside it easier then using a touched event.

2 Likes