Sound to Local Player didn't work

So, I wanted to make an Error sound for only one Client, but it’s not working

This is my script, did I make a mistake? sorry I’m new to scripting

-- Local Script
local RS = game:GetService("ReplicatedStorage")
local Sound = RS:WaitForChild("Sound")
local Error = workspace.AcidPart.Error
local PP = Error.Parent.ProximityPrompt

Sound:FireServer(Error)

-- Script
local RS = game:GetService("ReplicatedStorage")
local Sound = RS:WaitForChild("Sound")
local PP = workspace.AcidPart.ProximityPrompt

Sound.OnServerEvent:Connect(function(Error)
	Error:Play()
end)

Please correct if there is an mistake in my script.

Sound.OnServerEvent:Connect(function(player, Error)
	Error:Play()
end)

Try this instead. You forgot to include player in your parameters.

Also under the assumption you want this to only play for LocalPlayer, why couldn’t you handle it all on the client? I’d also recommend not keeping the sound in workspace, it’d be easier to keep it somewhere like SoundService and play it from there unless you have actual reason to keep it in workspace (ie. you want it to come from a certain place).

As he said, this script, even if it worked, it would play it for EVERY client and not only for one, just handle everything locally, it’s generally better.

Is there a way for me to make the sound only heard by one player? any examples?

You can simply play a sound on a local script, and that’ll play it for the client only

It didn’t work, I’ve tried before making this topic.

Do something like this :

local RS = game:GetService("ReplicatedStorage")
local Sound = RS:WaitForChild("Sound")

while true do
	if Sound.IsPlaying == false then
		Sound:Play()
	end
	task.wait(1)
end

This would consistently play the sound only on the client

With your case :

--Under a Part in Workspace
local Porx = script.Parent
local Part = Porx.Parent


Porx.Triggered:Connect(function(Player)
	game.ReplicatedStorage.RemoteEvent:FireClient(Player)
end)
-- Local Script
local RS = game:GetService("ReplicatedStorage")
local Sound = RS:WaitForChild("Sound")
local event = RS:WaitForChild("RemoteEvent")


event.OnClientEvent:Connect(function(Plr)
	Sound:Play()
end)

Also, make sure you own / have perms to that sound

It work! there were a few that didn’t work, I changed a bit and it worked! thank you!

1 Like
while true do
	if not sound.IsPlaying then
		sound:Play()
	end
	sound.Ended:Wait()
end
1 Like

I am amazed by how brief and informative your posts are, incredible!

I actually never used the event Ended , nice to know it’s useful.