Sounds are not as good as they could be. They’re not bad, but they’re underdeveloped. In my experiences there are three types of sounds:
Ambient sounds / music that are meant to play indefinitely and as soon as they’re loaded
Sound effects that are only meant to play once
Miscellaneous sounds from the two previous categories that need to be stopped/paused, have their pitch adjusted, etc
This thread provided a wonderful method of making the first category easy to use. The sound objects are just fine for the third category. As for the second category though, creating a sound object is just tedious and unnecessary. Since sound behavior was updated (playing sounds cancels any other sound currently playing from the same sound object), we can no longer just create a general “gun fire” sound effect object and play it each time the gun fires – every shot would stop the sound effect of the previous, producing an ugly sound clipping effect. To accomplish effects like that now, we have to resort to:
function playSound(soundId, emitter, volume, pitch, startTime)
local sound = Instance.new("Sound", emitter or game.Players.LocalPlayer.PlayerGui)
sound.SoundId = soundID
sound.Volume = volume or 1
sound.Pitch = pitch or 1
sound.TimePosition = startTime or 0
sound:Play()
sound:Destroy()
end
playSound("rbxassetid://1111111", tool.Barrel)
Not only is that playSound function something I (and I assume others who don’t want to type out 7 lines each time they play a sound) use on a constant basis, but you can see that I’m destroying the sound as soon as I create it because I didn’t need a sound object in the first place.
SoundService:PlaySound(soundId, emitter, volume, pitch, startTime) would not only save myself and anyone else who creates playSound functions in every script that plays sounds time and keep our scripts clean, but if implemented correctly it would alleviate the need to create a sound object to play sound effects.
If there is no emitter:
local script: Play sound for client (equivalent to parenting it to the PlayerGui)
server script: Play sound for everyone without 3D location (equivalent to workspace)? Not sure how you want to handle this, and quite frankly am not concerned about this as I handle sounds client-side.