Zone
Construtors¶
new¶
local zone = Zone.new(container)
fromRegion¶
local zone = Zone.fromRegion(cframe, size)
:relocate()
on that zone (which parents it outside of workspace), then finally returning the zone.
Methods¶
findLocalPlayer¶
local isWithinZoneBool = zone:findLocalPlayer()
findPlayer¶
local isWithinZoneBool = zone:findPlayer(player)
findPart¶
local isWithinZoneBool, touchingZoneParts = zone:findPart(basePart)
findItem¶
local isWithinZoneBool, touchingZoneParts = zone:findItem(basePartOrCharacter)
findPoint¶
local isWithinZoneBool, touchingZoneParts = zone:findPoint(position)
getPlayers¶
local playersArray = zone:getPlayers()
getParts¶
local partsArray = zone:getParts()
getItems¶
local itemsArray = zone:getItems()
getRandomPoint¶
local randomVector, touchingZonePartsArray = zone:getRandomPoint()
Vector3
and a table array
of group parts the point falls within.
trackItem¶
zone:trackItem(characterOrBasePart)
An item can be any BasePart or Character/NPC (i.e. a model with a Humanoid and HumanoidRootPart). Once tracked, it can be listened for with the zone.itemEntered
and zone.itemExited
events.
An item will be automatically untracked if destroyed or has its parent set to nil
.
untrackItem¶
zone:untrackItem(characterOrBasePart)
bindToGroup¶
zone:bindToGroup(settingsGroupName)
This method is particularly useful for zones where you want to guarantee the player/item is not in two zones at once. For example, when working with ambient/music/lighting zones which perfectly border each other.
unbindFromGroup¶
zone:bindToGroup(settingsGroupName)
setDetection¶
zone:setDetection(enumIdOrName)
relocate¶
zone:relocate()
onItemEnter¶
zone:onItemEnter(characterOrBasePart, callbackFunction)
local item = character:FindFirstChild("HumanoidRootPart")
zone:onItemEnter(item, function()
print("The item has entered the zone!"))
end)
onItemExit¶
zone:onItemExit(characterOrBasePart, callbackFunction)
local item = character:FindFirstChild("HumanoidRootPart")
zone:onItemExit(item, function()
print("The item has exited the zone!"))
end)
destroy¶
zone:destroy()
Events¶
localPlayerEntered¶
{client-only}
zone.localPlayerEntered:Connect(function()
print("you entered the zone!")
end)
localPlayerExited¶
{client-only}
zone.localPlayerExited:Connect(function()
print("you exited the zone!")
end)
playerEntered¶
zone.playerEntered:Connect(function(player)
print(("player '%s' entered the zone!"):format(player.Name))
end)
playerExited¶
zone.playerExited:Connect(function(player)
print(("player '%s' exited the zone!"):format(player.Name))
end)
partEntered¶
zone.partEntered:Connect(function(part)
print(("part '%s' entered the zone!"):format(part.Name))
end)
Info
This event works only for unanchored parts and may interfere with the parts CanCollide property. It's recommended to use itemEntered instead where possible which is more optimal and overcomes these problems.
partExited¶
zone.partExited:Connect(function(part)
print(("part '%s' exited the zone!"):format(part.Name))
end)
Info
This event works only for unanchored parts and may interfere with the parts CanCollide property. It's recommended to use itemExited instead where possible which is more optimal and overcomes these problems.
itemEntered¶
zone.itemEntered:Connect(function(item)
print(("item '%s' entered the zone!"):format(item.Name))
end)
itemExited¶
zone.itemExited:Connect(function(item)
print(("item '%s' exited the zone!"):format(item.Name))
end)
Properties¶
accuracy¶
local accuracyEnumId = zone.accuracy --[default: 'Zone.enum.Accuracy.High']
accuracy
you can use setAccuracy or do:
zone.accuracy = Zone.enum.Accuracy.ITEM_NAME
A list of Accuracy enum items can be found at Accuracy Enum.
enterDetection¶
local enterDetection = zone.enterDetection --[default: 'Zone.enum.Detection.Automatic']
zone.enterDetection = Zone.enum.Detection.ITEM_NAME
A list of Detection enum items can be found at Detection Enum.
exitDetection¶
local exitDetection = zone.exitDetection --[default: 'Zone.enum.Detection.Automatic']
zone.exitDetection = Zone.enum.Detection.ITEM_NAME
A list of Detection enum items can be found at Detection Enum.
autoUpdate¶
local bool = zone.autoUpdate --[default: 'true']
true
, the zone will update when its group parts change size or position, or when a descendant group part is added or removed from the group.
respectUpdateQueue¶
local bool = zone.respectUpdateQueue --[default: 'true']
true
, will prevent the internal _update()
from being called multiple times within a 0.1 second period.
zoneParts¶
{read-only}
An array of baseparts, defined in the container
constructor parameter, that form the zone.
region¶
{read-only}
volume¶
{read-only}
worldModel¶
{read-only}