Help with playing sound for only the one that activated it. (so nobody else hears it)

So this is my script:

door = script.Parent
function onChatted(msg, recipient, speaker)
source = string.lower(speaker.Name)
msg = string.lower(msg)
thecharacter = script.Parent.TheCharacter
if (msg == string.lower(thecharacter.Value)) then
door.CanCollide = false
door.Transparency = 0.7
local sound =“Sound”)
sound.SoundId = “rbxassetid://1839997962”
sound.Looped = false
sound.Parent = workspace
door.CanCollide = true
door.Transparency = 0
plr.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, plr) end)

I’ve checked some posts but I don’t understand the thing with RemoteEvent I’ve also checked the official Roblox guide too RemoteEvent | Documentation - Roblox Creator Hub

I have checked but still don’t understand. Im a noobie as you probably see so any help is appreciated :smiley:

1 Like

just make it a local script. local scripts only run for the client

1 Like

So if this is a server script then you will need a remote event. I’ll try to explain it step by step.

in ReplicatedService insert a remote event and call it PlaySound

In a local script (inside of: starter player scripts) you will want to make a variable referencing the remote event as well as one referencing the LocalPlayer

Next you want to connect the remote event, to do this do:

    —I’m here play your sound cue

Then all that’s left is in your original script just call remoteEvent:FireClient(playerThatActivated) when you want to run it