Problem with sound hearing for everyone

So i am trying to make sound play when player touches it and only the player who touches the block heares the “Scream sound”.

local played = false
script.Parent.Touched:Connect(function(hit)
	if played == false then
		workspace.SoundLibrary.Scream:Play() --these are Sounds and The Folder in the workspace
		played = true
		wait (5) 
		played = false
	end
end)

1 Like

Maybe fire a remote event and make the client listen for the event to be triggered, then add the sound in the local script.

i dont know how to do that :frowning:

Then I recommend you search up tutorials on YouTube to learn how to make it.

1 Like

Look here.

1 Like

So will i create RemoteEvent and put it to replicatedstorage then put this script

  1. local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
  • local remoteEvent = ReplicatedStorage:WaitForChild(“RemoteEventTest”)
  • – Fire the remote event
  1. remoteEvent:FireServer()
    in local script serverscriptservice then
    make my script
    local played = false
    remoteEvent:FireServer.script.Parent.Touched:Connect(function(hit)
    if played == false then
    workspace.SoundLibrary.Scream:Play() --these are Sounds and The Folder in the workspace
    played = true
    wait (5)
    played = false
    end
    end)

Although I don’t get what is the problem currently? If it is being done in a localscript, couldn’t you just use a Server Sided script to connect it?

I am trying it right now maybe it works

you can make the script in localscript and play the sound from there noone will hear it other then the client who touched it

1 Like

So will i just copy my old script and put it local script in serverscriptservice or where?

you can make the localscript in playerscripts and edit the path of touched event like game.Workspace["Part"].Touched for example and you should be good to go

1 Like

I dont understand omg im stupid maybe. Im new in remotevents

Yes, just create a new LocalScript, put it inside the part that makes the Scream sound when you touch and make the script play that sound after you touch it, because we’re using LocalScript that will only be heard to the LocalPlayer (Client / Your Computer).

local played = false
script.Parent.Touched:Connect(function()
	if played == false then
		workspace.SoundLibrary.Scream:Play() 
		played = true
		wait (5) 
		played = false
	end
end)

No need to use any RemoteEvents for this method.

this won’t work due to limitation of localscript see here localscript limit
you need either putting it in backpack or the character or playerscripts or playergui correct me if i am wrong

2 Likes
local played = false
script.Parent.Touched:Connect(function(hit)
  if not played then
    workspace.SoundLibrary.Scream:Play()
    played = true
    wait(5)
    played = false
   end 
end)

Try to do this one. Maybe it’ll work.

Oh yes, my mistake, you’re absolutely right. You need to put the LocalScript inside an object that the LocalScript has access to. Places such as StarterPlayer, StarterCharacterScripts, StarterPlayerScripts, StarterGui, StarterPack…

1 Like

It doesn’t work sorry bro i have to go school 1 sec

You could just make that script on the client if you aren’t aware of how remotes work. To do this simply just make a LocalScript, create the audio inside the script locally, then play it when someone touches it.

1 Like

That also works too. Even if you don’t have any knowlege of remotes, this’ll also make things even easier.

Can anyone make screenshots for better understanding Please. Thanks!