Very neat module service! I’ve been looking for a way to reliably detect if a player is inside a set area without having to delve too much into complicated scripting for an upcoming project pertaining to the Fallout genre (for instance, I’ll be using this to detect if a player is in a radioactive zone and add rads) and some other minor projects; this module/service provides just that and reliably so.
This is awesome! I already started making a few things which were made easier thanks to this module.
Anyway I got a question. One of the projects I am working on is a capture point system, which is being inspired from the capture points in Star Wars: Battlefront 2. So, right now, using playerEntered and playerExited, I count the amount of players there is on the point and what teams there on, so it counts how many defenders and attackers are on the point. That way, I wanted to see if I can implement a contesting state.
The problem here is that sometimes the amount of players on either team can go to negative or , which bothers me since obviously it would benefit the other team. So far, the different scenarios where it went negative was dying and then the body parts exiting the point or when a player changes team, then dying, it counts for the other team player count, etc. I’m not really too good with scripting but… Any help, please? (All I have right now is detecting players entering and exiting, which adds or subtracts to the team count.)
Edit: I managed to fix the team changing problem, so the only problem now is when a player dies, and the body parts fall out, I think it counts as the player maybe? I think?
Zone detection is ‘Automatic’ by default (i.e. which will almost always default to ‘WholeBody’) so that would require all character parts to leave the zone before the exited event is fired. If this doesn’t happen, can you DM me please and we can take a look to see if it’s an issue on our end.
If you would like to change the detection from whole-body to just the centre of the HumanoidRootPart, you can do:
All methods, and the player and localplayer events utilise Region3, RotatedRegion3 and/or Raycast checks. Only the experimental part events use touched events (combined with the new BasePart.CanTouch property), and these touched events are only ever formed if you connect to one of the zone part events (i.e. zone.partEntered or zone.partExited).
You can find further details at the Methodology page or feel free to ask here.
Thanks for the info! - Also, if I plan on having multiple points. Would having a module script in each zone part with the capture point settings be better or will having one set of settings inside the main script be good?
The _update method (triggered by a position change) only performs basic mathematical calculations and organisations of tables, and this is in addition to the 9(+1) cap of updates per second (which would otherwise be exceeded if you were dragging a zone part for instance), so you should be absolutely fine.
Whenever I call zone:getPlayers() I get this error,
17:53:06.943 ReplicatedStorage.Modules.Zone.ZoneController:450: attempt to compare nil and number - Server - ZoneController:450
17:53:06.944 Stack Begin - Studio
17:53:06.945 Script 'ReplicatedStorage.Modules.Zone.ZoneController', Line 450 - function getTouchingZones - Studio - ZoneController:450
17:53:06.946 Script 'ReplicatedStorage.Modules.Zone.ZoneController', Line 327 - function _getZonesAndPlayers - Studio - ZoneController:327
17:53:06.946 Script 'ReplicatedStorage.Modules.Zone', Line 735 - function getPlayers - Studio - Zone:735
17:53:06.947 Script 'ServerScriptService.Script', Line 1016 - Studio - Script:1016
17:53:06.947 Script 'ReplicatedStorage.Modules.Zone.Signal', Line 42 - Studio - Signal:42
17:53:06.947 Stack End - Studio
I’m trying to make entities spawn whenever you’re close to them