-- src/StarterPlayer/StarterCharacterScripts/SoundController.client.lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local SoundConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("SoundConfig")) local SoundEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("SoundEvent") local function playSound(soundName, position) local soundId = SoundConfig[soundName] if not soundId then return end local sound = Instance.new("Sound") sound.SoundId = soundId sound.Volume = SoundConfig.SFXVolume or 1 sound.RollOffMaxDistance = 100 if position then local att = Instance.new("Attachment") att.WorldPosition = position att.Parent = workspace.Terrain sound.Parent = att sound:Play() sound.Ended:Once(function() att:Destroy() end) else sound.Parent = workspace sound:Play() sound.Ended:Once(function() sound:Destroy() end) end end SoundEvent.OnClientEvent:Connect(function(soundName, position) playSound(soundName, position) end)