Why is there a delay when a player enteres a zone on the PlayerEntered event and PlayerExited?
Zone works as its suppose to work, that 's surely an issue with your coding
Baseplate.rbxl (75.3 KB)
This is the problem I told you before, where you can tell if you enter the cylinder area and sometimes jump, it will print â'Exitedâ even if you are still inside the cylinder.
Make sure to have âDecomposition Geometryâ Enabled.
Hello
When zone:setDetection is âWholeBodyâ, the âplayerEnteredâ event will be triggerred when all parts of the player are in the zone or if any part of the player is in the zone?
Thanks
The script seems to stop working if a player has died. When I try to enter the shop zone after dying, the shop gui doesnât show up. Do you know why is this happening?
You donât need to reply to yourself, thatâs considered spam. Where is your script located and what is the code?
yeah iâm having the same issue, not sure if its a glitch or what not but just disable
reset on spawn on the gui and it should work
This is the code that I used for my game. The script is also inside the gui. Do you know why the script wonât work after death?
just change the screen gui for the reset on spawn to be off
and i think itâll work
Let me try doing that. Iâll see if it works or not.
Hi, Iâm trying to make each Ambient Zone from the playground play a different sound depending on the time of day, but itâs just⌠not working. No errors in output, and everything is where it should be.
(This is the ambient zone script btw)
-- This creates a zone for every ambient group, then listens for when the local player enters and exits
local LABEL_DURATION = 3
local FADE_INFO = TweenInfo.new(1)
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local localPlayer = game.Players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AmbientContainer"
screenGui.ResetOnSpawn = false
screenGui.Parent = playerGui
local ambientAreas = workspace.AmbientAreas
for _, container in pairs(ambientAreas:GetChildren()) do
--
container:WaitForChild("Part", math.huge)
--
local zone = Zone.new(container)
zone:bindToGroup("EnterOnlyOneZoneAtATime")
local soundDay = container:FindFirstChild("Day")
local soundNight = container:FindFirstChild("Night")
-- if soundDay then
local areaLabel = Instance.new("TextLabel")
areaLabel.BackgroundTransparency = 1
areaLabel.Size = UDim2.new(1, 0, 0.08, 0)
areaLabel.Font = Enum.Font.Garamond
areaLabel.Text = container.Name
areaLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
areaLabel.TextTransparency = 1
areaLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
areaLabel.TextStrokeTransparency = 1
areaLabel.TextScaled = true
areaLabel.TextWrapped = true
areaLabel.Name = container.Name
areaLabel.Parent = screenGui
local endLabel = Instance.new("BindableEvent")
-- soundDay.Name = container.Name
-- soundDay.Parent = screenGui
zone.localPlayerEntered:Connect(function()
while true do
wait(0.1)
if game.Lighting.ClockTime >= 7 and game.Lighting.ClockTime <= 20 and soundDay.IsPlaying == false and soundNight.IsPlaying == true then
soundNight:Stop()
soundDay:Play()
elseif game.Lighting.ClockTime >= 21 and game.Lighting.ClockTime <= 6 and soundDay.IsPlaying == true and soundNight.IsPlaying == false then
soundNight:Play()
soundDay:Stop()
end
end
-- tweenService:Create(soundDay, FADE_INFO, {Volume = originalVolume}):Play()
tweenService:Create(areaLabel, FADE_INFO, {TextTransparency = 0, TextStrokeTransparency = 0.3}):Play()
local ended = false
task.spawn(function()
local endTick = tick() + LABEL_DURATION
repeat runService.Heartbeat:Wait() until tick() >= endTick or ended
if not ended then
endLabel:Fire()
end
end)
endLabel.Event:Wait()
ended = true
tweenService:Create(areaLabel, FADE_INFO, {TextTransparency = 1, TextStrokeTransparency = 1}):Play()
zone.localPlayerExited:Connect(function()
-- local fade = tweenService:Create(soundDay, FADE_INFO, {Volume = 0})
-- fade:Play()
endLabel:Fire()
-- fade.Completed:Wait()
-- fade:Destroy()
end)
end)
end
--end
Idk what iâm doing wrong
Where is this script located at?
And you have a while true do loop running when it doesnât need one, and itâs also blocking the rest of the code block from running.
Itâs the default Ambient Zone script, itâs at StarterPlayerScripts
Hello, this looks really cool!
Is there a way to see if a part is fully inside a zone, not partly.
Thanks
Hey mate I think I found a bug. I was trying to use this module for a door system, where if youâre nearby you can click E to open it. The module worked great when I ran zone:playerAdded(); zone:playerExited()
, however it didnât work as well with zone:getPlayers()
. Im not sure what the error could be, as I havent looked over the source code, however if it helps, I fired a part from the server, to the client (for a ui), then back over to the server where the script is located. I tried this without firing the part to clients and servers, by directly indexing it, and the same issue occured. In the script that is fired to last, the one that handles the door opening, I first get the part, then create a new zone using zone.new()
, then finally run zone:getPlayers
. My character was clearly inside of the part, however the table returned {}
instead of {game.Players.MemezyDev}
. Im not sure what the issue was since half the times it worked, other times it didnt. Maybe you could look over the code and see what the issue was for anybody in the future?
Not currently Iâm afraid due to the way spatial queries work. That could make a good roblox feature request, for instance WorldRoot:GetPartsFullyInPart(PartInstance part, OverlapParams overlapParams)
Itâs worth noting playerAdded and playerExited are events which you connect to instead of calling, e.g. zone.playerAdded:Connect(func)
. Itâd be best to share a link to an uncopylocked place if youâre still having troubles.
If you want me to I could, however I used an alternate method of this that worked, so I would need to remember the exact code I wrote down, pretty sure I forgot what I wrote at the time of making my comment
Just implemented this into my new game, its absolutely amazing and makes things so much easier. Very simple to use and implement 10/10
Iâm having an issue where the playerExited event randomly doesnât fire for a zone, and subsequently, none of the entered/exited events fire for any of the zones. Itâs so strange because it doesnât happen consistently with any one action or zone. It just randomly seems to happen and I have no idea how to fix it lol.
This module fails to work when you are using 2 partEntered or partExited events if both models which are bound to those events have the same parent.