Sound in LocalScripts doesn't play locally

Hey,

I have a small problem, I hope theres a quick fix for that.

This LocalScript is in StarterPlayerScripts:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local HumanoidRootPart = Character:waitForChild("HumanoidRootPart")

local Beam = script:WaitForChild("Beam"):Clone()

local function CreateBeam(Beam, Attachment0, part)
	local Attachment1 = part:FindFirstChild("Attachment")

	if Attachment1 then
		Beam.Attachment0 =Attachment1
		Beam.Attachment1 =Attachment0
	end
end

local ArrowEventSound = script:WaitForChild("FirstTask")--this line
game.ReplicatedStorage.ArrowEvent.OnClientEvent:Connect(function(part, Value)
	if Value == true then
		local Attachment0 = HumanoidRootPart:FindFirstChild("RootRigAttachment")
		CreateBeam(Beam, Attachment0, part)
		Beam.Parent = Character
	elseif Value == false and Player.Backpack:FindFirstChild("Wheelbarrow") then
		Beam:Remove()
	elseif Value == false then
		ArrowEventSound:Play()
		Beam:Remove()
	end
end)

image

You see, the sound should play locally. But it doesn’t. Every player can hear the sound.
How do I fix that?

Would it be possible to show me the line of code on the server end of things that fires this remote event?

local Tool = script.Parent
local Player1 = Tool.Parent
local Player = game.Players:GetPlayerFromCharacter(Player1)
--warn(20)
--warn("abcdef "..Player.Team.Name)
local ArrowEvent = game.ReplicatedStorage:WaitForChild("ArrowEvent")
local Team = Player.Team.Name
local ArrowbeamEnd = workspace["Zednov's Tycoon Kit"].Tycoons[tostring(Team)].PurchasedObjects.Wheelbarrow.End.Part1 --here add a reference to wherevever Wheelbarrow.End.Part1 is


Tool.Equipped:Connect(function()
	ArrowEvent:FireClient(Player,ArrowbeamEnd,true)
	
end)
Tool.Unequipped:Connect(function()
	ArrowEvent:FireClient(Player,ArrowbeamEnd,false)
end)

ServerStorage → Tool → Script

In soundservice, is RespectFilteringEnabled on or off? if it is off, then that explains your issue.

2 Likes

It is enabled. So that shouldn’t be the issue.

Can I see the tool object, with it’s children in the explorer? This will help me further debug your issue as I think I know what is happening here…

Put the sound in the workspace, then it will play

You can move the Sound to workspace or put it inside the StarterGui. This way only the player can hear it.

image

You shouldn’t need to use a serverscript to be listening for an equipped event. It’s actually documented that these events should be observed on the client. As far as the sound being placed into workspace i don’t believe this will have much of an impact. Could be wrong though…

https://developer.roblox.com/en-us/api-reference/class/Tool

This would probably be a good starting point to getting this fixed…

No, that didn’t solve the problem. :confused:

How would I transer the script into a LocalScript? What would I need to change?

To put it simply, just add the equipped and unequipped events into the localscript that already exists, and run your arrow event logic without having the remoteevent handling…

Couldn’t you just call PlayLocalSound() from that LocalScript? Sound replication is weird when it comes to instances such as these, so I’d recommend placing the Sound inside SoundService/workspace or somewhere alone those lines

So just replace Play() by PlayLocalSound() ?

Uh, im not a scripter, sorry. I dont really know how to do that :joy:

Yeah, keep in mind that you can only call this on the client side (LocalScripts)

1 Like

Doesn’t work :confused:


It’s a LocalScript.

Ah mistypos

It’s actually PlayLocalSound(), not LocalSoundPlay() :sweat_smile:

I also did that and it doesn’t work. In the dev thing you sent its made like this:
PlayLocalSound(ArrowEventSound) would that be right?