First things first,
I know there is multiple people who have had the same issue using this API. I’ve read multiple posts describing the same issue with events not firing/functions not running after resetting. Such as “Zone.playerEntered”.
Issue:
The API’s usage is very simple and works fine at a start, however after resetting your character the core functions of detecting when the player enters/exits a Zone stops working completely. I have no idea as to why this is, perhaps because the player object is being removed/readded to the workspace and the module doesn’t account for that. I’ve tried reinitalizing/recreating the zones when the character is readded but still no result.
If someone has a potential solution as to why this is or workaround that would be amazing. Otherwise if this issue can’t be fixed this API is basically just useless after your character dies. Mabey there is another alternative for zone detection that is smooth to implement/replace?
I can’t imagine that ZonePlus would fall to this simple of a problem. I am inclined to believe that it’s an implementation issue. Anyways, if all you want is to detect when a living player enters and leaves a specific, simple-geometry area, then I have a “minimalist version” of ZonePlus that you may try. I originally designed it to streamline spatial teleportation queues
I also find this issue to be extreme as it makes sense for this simple issue to be accounted for. It might very well be an implementation issue that I am failing to see. Now that I am thinking about it, could it be caused by the location of the Localscript where it is being ran/fired from? It’s currently located in PlayerGui. I didn’t think about it but it could have something to do with the script being recreated/reloaded when respawning since the instance gets destroyed when dying?
I’m sure the main programmer for ZonePlus, @ForeverHD can give you a more detailed explanation regarding this, however, I’ve been using ZonePlus for years and have never encountered this.
But, for your case what you could try to do is store every player who enters a zone in a table and when they leave, using playerExited, remove them from the table. This works for me.
zone.playerEntered:Connect(function(plr)
if PlayersInZone[plr] then
return
end
PlayersInZone[plr] = true
end)
There is a concern in that area. When attempting to access Player.Character in a LocalScript under StarterGui, the accessed character has a chance to be the player’s dead character. The LocalScript in question can execute early enough in this context where Player.Character has not yet been nullified or overridden to the new character
This does make sense. I suppose I could move the Zone events/handling to a Server sided script and fire necessary information to the client when entering/leaving. It adds an extra step but if it fixes the problem I guess I don’t have any other choice.
Like I predicted the issue was being caused by the location of the localscript. I was initially checking zone entering/leaving on the client inside PlayerGui. After resetting, the event connection and or script was being reset and therefor stopped working.
I moved the detection to a script inside ServerScriptService and simply fired to the client whenever they entered/left the specific zone.