Would multiple :FindPartsInRegion3 lag if it were checking every 1 second?

Would multiple :FindPartsInRegion3 lag if it were checking every 1 second? There’s likely to be anywhere from 4 to 40+ of these checks in the game running via server script. I’m unsure if it’d be great performance wise or not, so I of course thought it’d be better to ask before going back to thinking of a solution.

I’ve tried using ZonePlus to avoid having to do this, but it interfered with other scripts in the game.

1 Like

All though I assume it won’t be too bad, it can still be pretty detrimental to your game. It’s pretty hard to say what you should substitute this for, since we don’t know what you’re doing with it, but in short yes, it would cause issues.

1 Like

Hmmm… at least I know that now.

What I’m going for is a script that detects when a certain part (placed by the player) is inside an area.

I’ve tried an invisible part that detects when a part enters (using ZonePlus), which worked. However, the part being placed cannot be placed within the zone as I’ve used this trick here to make the part detect collisions despite being CanCollide false.

How layered is your map? You could just skip ZonePlus or Region3 and fire a raycast downwards from the part. If your map doesn’t have floors or anything then you don’t need any kind of 3D cast like this because it’s ultimately more expensive to run.

There’s parts of the map that are closed off, so that’s no good.

I think I’ll just use if statements (which I honestly didn’t consider before making this post, woops) in the aforementioned collision detection to ignore parts with a certain name and go back to ZonePlus.

Could you explain your use case in detail? Having restricted parts of your map shouldn’t diminish the viability of downcasting and I can’t figure out why that’d be the case because a lot of your explanations as to what you’re trying to do are vague.

I don’t think it’s worth your time settling for less appropriate methods if there are better and more performant alternatives that you can use. I can’t exactly help you if you provide vague context though.

There are ceilings, trees, and a few other things that’d block off the sky. The models that have these zones would also in the same folder with some other buildings that also have ceilings. I don’t want to compromise on that last bit unless absolutely necessary as it means changing a bunch of other scripts around.

That’s context but not your use case. I’m asking for your use case. What are you exactly trying to do?

I’m trying to check for when a part is added/entered/placed into a certain zone/area.

Oh, gotcha, thank you! I do apologise in this case then, raycasting would not be an appropriate solution for what you want to achieve especially since with the context you would have 3D spaces to check for.

In terms of the original question, yes, ideally you don’t want to be polling any Region3 method whether or not it’s a raw Region3 method or a module that incorporates it like ZonePlus. I don’t imagine there’d be any logic you want to run while the object is in placement, but if there is then you might want to consider FindPartsInRegion3WithWhiteList.

I would never endorse using any method supporting Region3 without a whitelist, it’s just too computationally expensive if you intend to run it frequently. At that point if a whitelist doesn’t work I would just use pure math to check the position of the current object and see if its within the bounds of your area. I think Roblox has a method coming later that’ll make this process easier.

As for checking when the object is placed/added into your area of choice, you realistically would only need that region cast to happen one time and then you can cache the result of where that object was placed in but I’d still encourage the above whitelist method so that your Region3 isn’t casting over parts that are irrelevant to your placement or the region. You should be fine after that.

1 Like

There is one important thing I forgot to mention:

I also need to be able to check when the part exits or is taken out the zone/area.

Going back to ZonePlus is probably the best option that I can think of.

2 Likes