Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited by DeceptiveCaster 5 years ago

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!....

0
Use a remote event to have the sound play locally. DeceptiveCaster 3761 — 5y

2 answers

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
5 years ago

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.

0
I would enable RespectFilteringEnabled in SoundService(it's disabled by default). Unhumanly 152 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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!

Answer this question