-- src/ServerScriptService/SoundscapeManager.server.lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local SoundService = game:GetService("SoundService") local SoundConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("SoundConfig")) local SoundEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("SoundEvent") -- Create ambient sound groups local ambientGroup = Instance.new("SoundGroup") ambientGroup.Name = "Ambient" ambientGroup.Volume = SoundConfig.AmbientVolume ambientGroup.Parent = SoundService local sfxGroup = Instance.new("SoundGroup") sfxGroup.Name = "SFX" sfxGroup.Volume = SoundConfig.SFXVolume sfxGroup.Parent = SoundService -- Create ambient forest sound (looping) local forestSound = Instance.new("Sound") forestSound.Name = "ForestAmbient" forestSound.SoundId = SoundConfig.ForestAmbient forestSound.Looped = true forestSound.Volume = 0.3 forestSound.SoundGroup = ambientGroup forestSound.Parent = workspace -- Start ambient forestSound:Play() -- Handle client SFX requests SoundEvent.OnServerEvent:Connect(function(player, soundName, position) -- Relay to all nearby clients if SoundConfig[soundName] then for _, otherPlayer in ipairs(game:GetService("Players"):GetPlayers()) do if otherPlayer ~= player then SoundEvent:FireClient(otherPlayer, soundName, position) end end end end) -- Expose for server-side sound triggering _G.PlayWorldSound = function(soundName, position) for _, player in ipairs(game:GetService("Players"):GetPlayers()) do SoundEvent:FireClient(player, soundName, position) end end print("Soundscape Manager initialized")