I have seen your game, and you have these walls which players go through in order to progress.
To do this, when a player joins you can set a default value. For example; if a player just joins the game and your first level is where they spawn (duh), you set a variable to ‘1’.
Each time a player goes through a wall (You detect this using a collision handler which can be done by many things, .Touched is one of them), you check if the value you assigned is greater than the one assigned to that wall, and if the condition returns ‘true’ then your player has walked back to a previous level, but if it returns ‘false’, the player has advanced to another level. Each time this happens, update the player’s value to the respective level value.
If you have a teleportation feature in your game, say, to sell things; you can just set the variable to the default value (eg. 1).
An event would probably cause the least lag, but a loop that runs on the server (and uses RemoteEvents, if needed) shouldn’t be an issue. FindPartsInRegion3WithWhiteList is probably most efficient with this and very easy to set up, however with the limitation that the Regions used have to be axis-aligned and can not be rotated or differ from a cuboid in any way.
Couldn’t you have Region3 “Borders” around the edges of each map, as well as Touched Events near all Spawn/Teleportation Points? It definitely won’t be as costly as scanning the entire area for the player’s presence.
Yeah, but if I did the check every 5 seconds and have 10 maps, there would be 10 Region3 checks every 5 seconds. Sounds a bit expensive to me but I am not sure. If I had to make use of any Touched Events, then I might as well not need the Region3, however, what I am afraid of is the number of times the event will be unnecessarily triggered.
I can guarantee you Region3s are most efficient and least costly, but I’m just not sure how costly it is in your scenario. As you said, touched events are very unpredictable, and sometimes rare cases occur. For example, a group of players piling up on a spawn means that not everyone would touch the spawn.
you can just whitelist a folder that will contains invisible and big parts for everymap, they should be invisible and can collide = false
then you just add the folder to the region3 and the parts that will find the script are only those blocks.
As the scripts or tools that use the player:GetMouse() to detect parts or whatever, you can just add this: Mouse.TargetFilter = folder_where_are_the_blocks and the mouse will ignore them.
More info:
then with this know you have just one region3 looping every x seconds only to know where the humanoidrootpart is instead of too many touch parts or too many region3 for every part.
Although it makes a lot of sense because with your method there won’t be any unnecessary Region3’s created, I will still stick to the method I have marked as a solution for the reason being that it doesn’t involve any Region3 checks. However I very much appreciate your response.
but using the nearest position of the humanoid isn’t the best, and the region3 can work with local scripts well and doesn’t do a region3 for every part, just a region 3, and the nearest position will involve using maybe a .magnitude check for every part.
Forgot to say but I needed the server to know where the characters are at so I had to use the server side. What I did was a nearest number check for the Z axis of the HumanoidRootPart and the bases of the maps because my maps are all on the Z axis. The method is working perfectly fine.
Get the HumanoidRootPart of the player, and ensure there is a HumanoidRootPart
Get the Local Difference by using the formula (Hitbox.CFrame - Hitbox.CFrame.p):inverse() * (HumanoidRootPart.Position - Hitbox.Position)
Check that the player is inside the Hitbox by doing checks on the X and Z axis of the Local Difference by doing math.abs(LocalDifference.X) < Hitbox.Size.X / 2
If both of those checks return true, the player is inside the box, otherwise they aren’t!