I’m trying to use GetPartBoundsInBox to check for players in a box, but it isn’t working properly, it works sometimes and doesn’t during others. There’s no errors either, I think it might have something to do with the max parts limit but I’m not sure.
Region:

Output::
Code:
1 Like
Does anything change when you use WorldRoot:GetPartsInPart instead? Also, if you just set the overlapParam MaxParts to 0 (which is already the default), there shouldn’t be any limit to how many objects you can return.
1 Like
Hey Kyle, I tried setting MaxParts to 0, but it’s still only printing only 1 part’s name. Also, after changing it to PartsInPart, it still printed the same thing.
Code:

I believe I found your issue. You’re returning objectsInSpace inside of your iteration through the objectsInSpace table, which explains why it’s only printing one part.
Try putting it outside of the iteration, and I would imagine it would work as intended. 
However to add onto this, since you’re inserting the player inside of the objectsInSpace table, I believe the loop will continue to cycle through the players that have been added to the end of the table, and it may error.
What you could do to get around this is initialize an empty array within the function and just add the players to the empty array and return that instead of the whole objectsInSpace table (assuming you just want to know the players that are within the safe zone).