Hi here, I’ve been trying to experiment with ways to do this but I just can’t figure it out in the best way possible. How can I make a sound (in the workspace) ignore a group of players? It would make my life easier if that was built into the sound’s class but sadly not.
there could be a better solution but I believe in this case you would want to fire the specific clients that you want to hear the sound via remote event and then play it on the client
I already tried this solution but it didn’t work out too well. The problem if the player leaves the area where this song is supposed to play it continues playing just not on the client. I created a way around this but it was too buggy to fix and that’s not even including the delay that would be caused by the remote events. If no other solution comes up, I might try to remake this.
This is the other solution I tried. There are not one but many sound effects all with different volumes so managing them all is a real hassle. The solution I tried with this idea also didn’t work. For some reason the audio would start but after leaving the area then come back the client consistently reported the sound wasn’t playing but all I did was change the volume settings.
What exactly is your use case? I would probably fire the client every time the sound needs to toggled. It would look something like this:
-- Server
RemoteEvent:FireClient(player, sound)
-- Client
RemoteEvent.OnClientEvent:Connect(function(sound)
if sound.IsPlaying then
sound:Stop()
else
sound:Play()
end
end)
When you fire the client with the sound object, the client will check whether the sound is playing or not. If it is, the sound will stop playing and if it is not the sound will start playing.
I am guessing you are attempting to play a sound for certain areas. You could do this completely on the client by calculating which area they are in and playing said sound.
[[local script]]
local RF = Istance.new("RemoteFunction", workspace)
local Group = --The Group of the Player
while wait(4) do
local Check = RF:InvokeServer(Group)
if Check == true then
--Play Music
else
--Dont play the Music
end
end
[[server script]]
workspace.RemoteFunction.OnServerInvoke:Connect(function(Group)
if Group == "The name of the Group" then
return true
end
I would make a table that includes the list of players you want the sound to play, and have it clone a localscript that plays a specific sound in their character.