Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a Player hear a sound while the others don't? [Solved]

I made a little code... But It doesn't work

workspace.Level1.Platform.Touched:Connect(function(Hit)
		local Player = script.Parent.Parent.Parent.Parent.Name
		if Hit.name == Player.Name then
			script.Parent.Playing = true
		end
end)

Please tell me what to do!....

1 comment

0

Use a remote event to have the sound play locally.

2 answers

✓ Accepted answer

This is quite simple in fact.

If this is a server script:

Fire a remote to the player you want to hear the sound (See FireClient, RemoteEvents). This could also work with RemoteFunctions (See InvokeClient, RemoteFunctions).

Obtain the sound, place it wherever you want in the localscript and then proceed to play it. This will make only that one player hear it.

If this is already a local script, playing it will be sufficient.

1 comment

0

I would enable RespectFilteringEnabled in SoundService(it's disabled by default).

Well, I found a solution on YouTube! This is by AlvinBlox

SelectTheObject.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild('Humanoid') then
		game.Players[Hit.Parent.Name].PlayerGui.Sound:Play()
		game.Players[Hit.Parent.Name].PlayerGui.Sounds:Stop()
	end
end)

But Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.