Answered by
5 years ago Edited 5 years ago
I would probably use Remote Events. Here's what a localscript (inside of startergui) might look like:
1 | local r = game:GetService( "ReplicatedStorage" ) |
2 | r.playSound.OnClientEvent:connect( function (songName) |
3 | workspace [ songName ] :Play() |
And then in a regular script inside of ServerScriptService:
1 | local player = [ insert player to hear the sound ] |
2 | local soundId = [ sound name inside of workspace ] |
3 | local r = game:GetService( "ReplicatedStorage" ) |
4 | r.playSound:FireClient(plr,soundId) |
So yes, you do have to use localscripts, but you can integrate them with regular scripts.
Hope this helps!
EDIT:
As said in the comments by RSASDSA,
"SoundService.RespectFilteringEnabled must be on for this to work properly."
So in the regular script, you should add:
1 | game:GetService( "SoundService" ).RespectFilteringEnabled = true |