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.
COMMUNITY QUESTION
Can You Make A Sound Local Using a Global Script?
1 answer
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
2 comments
0
note: SoundService.RespectFilteringEnabled must be on for this to work properly
0
@RSASDSA, I added that to the answer! Thanks for letting me know.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
https://www.roblox.com/library/2580560341/SoundKit
you could change that around just throw the sound and gui into StarterGui and the event into Replicated Storage of course