Will this work for jumpscares?
This helped a lot, thank you!
(30 chars)
I really love Zone +, but for some reason it isnât working for me:
local RP = game:GetService("ReplicatedStorage")
local ZP = require(4664437268)
local ZS = require(ZP.ZoneService)
local zonePart = game.Workspace.ZonePart
local zone = ZS:createZone("Zone", zonePart)
--------------------------------------------------------
local playersInZone = zone:getPlayers()
zone.playerAdded:Connect(function(plr)
print(plr.Name.." Joined!")
end)
zone.playerRemoving:Connect(function(plr)
print(plr.Name.." Left!")
end)
zone:initLoop()
Nothing will print, and I wonât get any errors (ZonePart is a Part with CanCollide off)
I think the zonePart variable has to be a folder or model. Either one should work.
Thank you so much!!! I spent hours trying to find my mistake and just couldnât, youâre a life saver!
Hi, what are the best practices for setting up a zone / the limitations of this?
Currently I had just set up multiple zones, building on from the first one I had implemented as a test.
Hereâs what they look like in studio (color-coded)
Having all these zones enabled with a basic playerAdded
and initLoop
shoots my server Script Activity usage up to 25-30%. (Iâm assuming this from the MicroProfiler as well as disabling/enabling)
The same amount of zones works fine on the client without any significant frame drops.
Is the problem the number of parts the zones are over? Should I create flat zones under the map and use the height parameter? Iâm wondering if I can find a solution to this, for now Iâve temporarily disabled them on the server. Any help is appreciated
Good question, Iâve included a Best Practises section to cover all your points and some additional:
In short, for your situation, use Zone+ on the client, minimise the height (therefore volume) of your zones where possible, and specify a longer delay for the loop, such as :initClientLoop(3)
.
If a collection of zone parts have a height of 10, while another has a height of 9 and an additionalHeight of 1, then they both effectively have the same height (and volume). Reducing any zones total height though will improve its performance (this is negligible for small zones).
Hello, Great Zone+
If you keep the zone area 200x200x200 or less, on average how many zones can you have and not see performance issues?
10, 20, 50 , 100?
Thanks!
This depends on a few factors youâll need to determine yourself:
-
Whether the zone is on the server or client (and calling
initClientLoop
)
If the latter, a zones volume can be as large as you like with minimal-no impact on performance as it only performs raycast checks. Otherwise if server, then you will notice performance impacts the greater a zones volume due to additional Region3 checks. -
How often checks are performed
You could construct 1000 zones of size 1000x1000x1000 and be perfectly fine. Itâs when you begin to call:getPlayer()
and:getPlayers()
frequently (whichinitLoop()
does 600 times per minute per zone unless you specify a greater delay such asinitLoop(3)
) for lots of zones where things become extremely intensive. For instance, if you have 100 zones of size 200x200x200 and callinitLoop()
on all of these without specifying a delay, youâll be performing 60,000 Region3 and Raycast checks over a volume of 800,000,000 studs cubed per minute. Thatâs going to hurt.
On the server, If you intend to setup lots of zones on the server with large volumes, or if your zones cover your entire map, youâll honestly be better off setting up your own detection system which fires a raycast from every players HRP every interval.
Zone+ events on the server are primarily optimised and intended for servers with lots of players with zones that do not cover a large proportion of the map.
Just wanted to point out that the current code doesnât seem to support wedges or parts at odd angles. Only partial workaround this is by unioning said parts.
Iâm having an issue where it only makes a zone for one part in the model I am making a zone out of. This is my code:
local serverStorage = game:GetService("ServerStorage")
local zonePlus = require(4664437268)
local zoneService = require(zonePlus.ZoneService)
local zoneParts = workspace:WaitForChild("ZoneParts")
local zone = zoneService:createZone("ArenaZone", zoneParts)
local items = serverStorage:WaitForChild("Items")
zone.playerAdded:Connect(function(player)
if player.Character then
items:FindFirstChild(serverStorage.PlayerData[player.Name].EquippedItem.Value):Clone().Parent = player.Backpack
end
end)
zone.playerRemoving:Connect(function(player)
if player.Character then
player.Character:FindFirstChildOfClass("Humanoid"):UnequipTools()
local item = player.Backpack:FindFirstChild(serverStorage.PlayerData[player.Name].EquippedItem.Value)
if item then
item:Destroy()
end
end
end)
zone:initLoop()
Your code appears to be fine at a glance. Can you send a picture of zoneParts and their descendants in workspace? Have you made sure the parent is a model or folder?
Sure.
Iâm making a room detection system for my game and itâs worked great so far to detect which room each player is in.
I know this isnât a feature of the module, and neither is it intended, but what do you suggest for detecting non-player objects such as a thermometer detecting which room it is currently in.
Thereâs a few methods you could use in your scenario and it ultimately depends on how your tools/objects behave (i.e. can they move at all, can they be picked up by players, etc).
First idea which springs to mind: group invisible parts together to represent a room and place them slightly below the room itself, then whenever you need to know which room the thermometer is in, fire a raycast downwards and if it hits one of these parts you can deduce which room its in.
Has anyone used this for hitboxes? All the existing solutions I have looked at arenât good for my use case so far. using just regular .Touched doesnt reliably fire if the hitbox isnt moving.
I was wondering this aswell while looking at this topic.
Zone+ can be used to generate hitboxes. Keep in mind itâs primarily intended to work with static areas as apposed to dynamically changing areas. For this reason Iâd explore other resources such as swordphinâs Raycast Hitbox module:
Hey Iâve been using Zone+ recently (itâs an amazing module). However, Iâve been running into some problems recently.
Iâve been making two zones for a music changer and an environment name popup thingy. There has been this bug and itâs IS SO FRUSTRATING. This is happening on the client (I use it correctly):
This is a class that is integrated with Quentyâs Binder class
function EnvironmentRegion:_connectModel(model)
local zone = Zone.new(model)
zone.playerAdded:Connect(function(player)
print(player.Name, "has entered", self:GetEnvironmentName())
EnvironmentName:Set("DisplayedText", self:GetEnvironmentName())
end)
zone.playerRemoving:Connect(function(player)
print(player.Name, "has left", self:GetEnvironmentName())
end)
self._maid:GiveTask(zone)
zone:initClientLoop(0.01)
print("Created EnvironmentRegion Zone For Model:", model:GetFullName())
end
-- I know this says MusicChangePart but it is actually a model (i'm looking to
-- change the name later)
function MusicChangePart:_connectModel(model)
local zone = Zone.new(model)
zone.playerAdded:Connect(function(player)
print("Switch background music")
SwitchBackgroundMusic({
SoundId = self:GetAudioAssetId(),
})
end)
zone.playerRemoving:Connect(function(player)
print("Left background")
SwitchBackgroundMusic({
SoundId = SwitchBackgroundMusic.DefaultBackgroundMusic,
})
end)
self._maid:GiveTask(zone)
print("Created MusicChangePart Zone For Model:", model:GetFullName())
zone:initClientLoop(0.01)
end
The major problem is that the behavior is extremely inconsistent. Sometimes, one zone works. Sometimes the other. Sometimes both zones work, and sometimes none work. It is really frustrating.
Also, It prints that the zones are created (both zones). I think itâs something to do with playerAdded and playerRemoving.
No errors at all.
Thanks.
Will this worked with lightings and atmospheres on only player client that wonât affect other players client?