This looks really useful and I would be using this in my future games and projects. Thanks for providing this
First of all Iād like to say great work and thanks for making this open source! Itās been really awesome to experiment and learn from your scripts. I did also have a question in regards to making a zone disable the core roblox backpack gui. Below is what Iāve drafted up.
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local ToolAreas = workspace.ToolAreas
local player = game:GetService("Players").LocalPlayer
local PlayerGui = player.PlayerGui
local tweenService = game:GetService("TweenService")
for _, container in pairs(ToolAreas:GetChildren()) do
local zone = Zone.new(container)
-- This is called when the localPlayer enters the zone
zone.localPlayerEntered:Connect(function()
player.PlayerGui.SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
end)
-- This is called when the localPlayer exits the zone
zone.localPlayerExited:Connect(function()
player.PlayerGui.SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
end)
end
Iām getting 0 Errors and 0 warnings in Script Analysis and am not sure where Iām going wrong. Iād appreciate any advice if possible.
Can you implement this necessary feature so that we can create āsmallā zones within the ābig motherā zone? For example, when a player enters a small zone (within the big mother zone) it exits from the big mother zone and then it enters into the small zone and when the player leaves the small zone then it leaves from the small zone and enters the big mother zone, hopefully you can understand since i didnāt find this feature in the api.
Your code looks fine except youāre calling SetCoreGuiEnabled
incorrectly:
player.PlayerGui.SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
should be:
player.PlayerGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
You can achieve this with solid modelling (making sure to set the unions collision fidelity to āPreciseā) and zone:bindToGroup
:
BindToGroup
for _, container in pairs(lightingAreas:GetChildren()) do
-- Construct the lighting zones and bind them to the same group to ensure that the localPlayer only enters one zone at a time
local zone = Zone.new(container)
zone:bindToGroup("EnterOnlyOneZoneAtATime")
-- This is called when the localPlayer enters the zone
zone.localPlayerEntered:Connect(function()
print("Entered:", container.Name)
tweenService:Create(lighting, TweenInfo.new(0.5), zoneLighting):Play()
end)
-- This is called when the localPlayer exits the zone
zone.localPlayerExited:Connect(function()
print("Exited:", container.Name)
tweenService:Create(lighting, TweenInfo.new(0.5), defaultLighting):Play()
end)
end
Solid Modelling
End Result
Ohh thatās actually smart, I didnāt think about that, Also itās a blessing that youāre still helping people here.
I found a major issue with this method which is the following:
So when using union, it makes multiple hit-boxes inside and that triggers the module so many times which is inconsistent, I donāt know how you would even fix this issue, Thatās what iām concerned of
(
I used this feature to show the hit-box geometry
)
(However this bug doesnāt occur to Block shapes as it has only one geometry)
Hey thanks for the response! But I actually am not seeing the difference between the lines I have in and what you suggested. It looks exactly the same.
What I have.
player.PlayerGui.SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
What you suggested
player.PlayerGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
I know this is how the whole module works so no need to take any action but do you have any other idea to implement my āmother zoneā and āsmall zoneā
ZonePlus functions with spatial queries instead of hit boxes so something there doesnāt sound right. Can you share a place file which reproduces this issue of yours?
I recommend testing with print("Entered")
and print("Exited")
. If that doesnāt work, feel free to share the details here. If the print statements do work correctly, I recommend asking for further help in #help-and-feedback
After more tests it seems that the bug can be reproduced by merging an union/a part with a negative part and setting the collision fidelity to āPreciseā, now the module will leave and enter multiple times if the player moves/jumps at some point
The module appears to be a bit buggy (works 50% of the time) when teleporting to a region about 20k studs away from the origin with streaming enabled opportunistic enabled. Used to works fine, but something went wrong after streamingenabled was modified and oppotunistic was enabled.
Can you send a repo place file of this as I canāt reproduce this myself
I canāt seem to reproduce this, even when moving the test place over 100,000 studs from the origin and setting the following properties for Streaming enabled:
Are you ensuring the parts have streamed in before constructing the zones? e.g:
lightingAreas:WaitForChild("Green", math.huge)
lightingAreas:WaitForChild("Pink", math.huge)
Iāve updated the playground if youād like to play around with this:
https://www.roblox.com/games/6166477769/ZonePlus-Playground
@ForeverHD
Found a weird bug with having .playerEntered on the client. Iāve provided a video and the code used.
Basically, the zone doesnāt detect a player ( if that 1 player has died ), both players have to die in order for it to be accurately detected once again.
Zone.playerEntered:Connect(function(Player)
print(Player)
end)
edit : the bug can not be replicated inside of roblox studio, only happens in game.
Thanks for your report! Iāve done some digging and it appears there were some cases with streaming which ZonePlus wasnāt accounting for. Updating the function on line 87
of the Tracker
module to the following should fix this:
local function playerAdded(player)
local function charAdded(character)
local function trackChar()
local hrp = character:WaitForChild("HumanoidRootPart", 0.1)
local humanoid = character:WaitForChild("Humanoid", 0.1)
local head = character:WaitForChild("Head", 0.1)
if hrp == nil or humanoid == nil or head == nil then
return
end
updatePlayerCharacters()
self:update()
for _, valueInstance in pairs(humanoid:GetChildren()) do
if valueInstance:IsA("NumberValue") then
valueInstance.Changed:Connect(function()
self:update()
end)
end
end
end
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp then
task.delay(0.1, trackChar)
else
character.ChildAdded:Connect(function(child)
if child.Name == "HumanoidRootPart" and child:IsA("BasePart") then
task.delay(0.1, trackChar)
end
end)
end
end
if player.Character then
charAdded(player.Character)
end
player.CharacterAdded:Connect(function(char)
charAdded(char)
end)
player.CharacterRemoving:Connect(function(removingCharacter)
self.exitDetections[removingCharacter] = nil
end)
end
Iāll deploy this change officially at a later date alongside a group of other updates.
My experiences were teleporting to the area instead of moving to it though, but let me try to send you something
Thanks, this solution works perfectly!