Skip to main content

Quickstart

Usage Example​

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ZoneService = require(ReplicatedStorage.ZoneService)
local Observer = ZoneService.Observer

local observer = Observer.new()
local zone = ZoneService.new(CFrame.new(10, 10, 10), Vector3.new(20, 20, 20), "Block", {dynamic = false, priority = 20, metadata = "SafeZone"})
observer:add(zone)

observer:onEnter(zone, function(player)
print(player.Name.." entered the zone!")
end)

observer:onExit(zone, function(player)
print(player.Name.." exited the zone!")
end)

Players.PlayerAdded:Connect(function(player)
local tracked = ZoneService:track(player)
observer:onZoneChange(tracked, function(zone)
print(player.Name.." is in "..(zone and zone.metadata))
end)
end)

Players.PlayerRemoving:Connect(function(player)
ZoneService:untrack(player)
end)