ZonePlus utilises the new Spatial Query API and Whitelists to effectively determine players, parts and custom items within a zone. You can have as many zones as you like, as large as you like, with zero-to-minimal additional cost to performance.
-- This constructs a zone based upon a group of parts in Workspace and listens for when a player enters and exits this group -- There are also the ``zone.localPlayerEntered`` and ``zone.localPlayerExited`` events for when you wish to listen to only the local player on the client local container = workspace.AModelOfPartsRepresentingTheZone local zone = Zone.new(container) zone.playerEntered:Connect(function(player) print(("%s entered the zone!"):format(player.Name)) end) zone.playerExited:Connect(function(player) print(("%s exited the zone!"):format(player.Name)) end)
-- This constructs a zone based upon a region, tracks a Zombie NPC, then listens for when the item (aka the Zombie) enters and exits the zone. local zoneCFrame = CFrame.new() local zoneSize = Vector3.new(100, 100, 100) local zone = Zone.fromRegion(zoneCFrame, zoneSize) zone.itemEntered:Connect(function(item) print(("%s entered the zone!"):format(item.Name)) end) zone.itemExited:Connect(function(item) print(("%s exited the zone!"):format(item.Name)) end) zone:trackItem(workspace.ZombieNPC)
-- This is a one-time use method which calls the given function when the given item enters the zone local item = character:FindFirstChild("HumanoidRootPart") zone:onItemEnter(item, function() print("The item has entered the zone!")) end)
Big thanks to these people for their resources and contributions:
- @Lucke0051 for assistance with the documentation
- @JohnnyMorganz for workflow guidance
- @pobammer for their Janitor class
- @stravant for their Good Signal class
ZonePlus is completely free and open source. It operates under an MIT License; you only have to provide credit and link back to this thread to use and modify. It’s taken a considerable amount of time to develop so any feedback is greatly appreciated!