What do you want to achieve? I am helping to make my friend’s game, and I’m wondering how it’s possible, I’m using ZonePlus for that
What is the issue? I don’t seem to find anything that lets me get playing sounds
What solutions have you tried so far? I looked around here and I don’t seem to find any
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = script.Parent
local zone = Zone.new(container)
zone.playerEntered:Connect(function(player)
-- sound playing
end)
zone.playerExited:Connect(function(player)
-- sound stopping
end)
I want to get a list of playing sounds because I don’t want to hear sounds outside of a certain area, I’m using ZonePlus to make it possible, and I don’t find a function for that
yea so if u have a sounds folder in ur workspace, you can easily make a table, add the playing ones into a list by looping through the children and checking the playing property of the sound, or descendants of the workspace if u dont have a sound folder, disable them when they enter a zone, and then re-enable them after they exit id reckon, using table.remove and table.insert
the problem is that the sound doesn’t stop playing even if I’m outside of a zone
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = script.Parent
local zone = Zone.new(container)
local sounds = script:GetChildren()
local PlayingSounds = {}
zone.playerEntered:Connect(function(player)
for i, v in sounds do
if v:IsA("Sound") then
v:Play()
if v.IsPlaying then
table.insert(PlayingSounds, v)
end
v.Ended:Connect(function()
table.remove(PlayingSounds, i)
end)
end
end
end)
zone.playerExited:Connect(function(player)
for i, v in sounds do
if v:IsA("Sound") then
if v.IsPlaying then
v:Stop()
table.remove(PlayingSounds, i)
end
end
end
end)