Hello everyone, I’m basing my sound storage system off of this post
The ModuleScripts where the sound data is stored looks like this:
local soundLibrary = {}
soundLibrary = {
["Name"] = {
["SoundId"] = "rbxassetid://123456",
},
-- The rest of the sounds
}
soundLibrary.DefaultValues = {
["Looped"] = false,
["PlaybackSpeed"] = 1.000,
["Volume"] = 0.500,
["RollOffMaxDistance"] = 10000,
["RollOffMinDistance"] = 10,
["RollOffMode"] = Enum.RollOffMode.Inverse,
}
Whenever I need to play a sound to all clients, I fire a RemoteEvent with the sound name and the clients create and play the Sound objects, using the information from the module, at the desired location:
-- Called by the client
function soundEmitter.emitSound(stringId, location)
local sound = Instance.new("Sound")
-- Returns a dictionary of the sound properties based on its entry in the sound library
local soundParams = soundEmitter.getSoundParams(stringId)
-- Sets the Sound's attributes to those from the dictionary
soundEmitter.assignValues(sound, soundParams)
sound.Parent = location
sound:Play()
Debris:AddItem(sound, sound.TimeLength)
end
However, some sounds do not play when they are called for the first time; I’m assuming it’s because the client needs a moment to download the sound data. What’s the best way to account for this if I were to use a system like this?