Is it possible to have a sound play for only the local player through use of a global script? I tried parenting a sound to the player's PlayerGui and then playing it, but that didn't seem to work. Any suggestions? Or do I have to use a LocalScript? Thanks in advance for anyone who helps out.
I would probably use Remote Events. Here's what a localscript (inside of startergui) might look like:
local r = game:GetService("ReplicatedStorage") r.playSound.OnClientEvent:connect(function(songName) workspace[songName]:Play() end)
And then in a regular script inside of ServerScriptService:
local player = [insert player to hear the sound] local soundId = [sound name inside of workspace] local r = game:GetService("ReplicatedStorage") 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:
game:GetService("SoundService").RespectFilteringEnabled = true