Local Player Sound effect for Text UI

So I’m making a dialog UI system for an NPC. When the UI appears and the text changes and appears, a sound effect like it’s typing it out.

Right now I’m having an issue where the sound plays correctly, but the audio is played in the workspace allowing everyone to hear the clicking sound effect which I don’t really want. Is there any way for the audio to be played to the local player who activated the UI?

Here’s the function.

function SoundEffect()
	local Sound = Instance.new("Sound", workspace)
	Sound.Name = "TextSound"
	Sound.SoundId = "http://www.roblox.com/asset/?id=3333976425"
	Sound.PlaybackSpeed = 0.8
	Sound.Volume = 1
	Sound.Volume = 1
	Sound:Play()
	coroutine.resume(coroutine.create(function()
		wait(1)
		Sound:Destroy()

	end))
end

If anyone knows any ways to get around this, that’ll be great. Thanks!

Just play the sound only on the client through the same Local Script that’s managing the UI. Sounds played locally won’t replicated to the server.

Sounds are not filtered by default. You have to enable RespectFilteringEnabled in the sound service to keep sounds from replicating, but that may keep player sounds from playing as well.

A better solution would be to create the sound object in the PlayerGui and play it from the localscript.

1 Like