Why Wont my sound work?

Hi developers,

I have a problem with my sound playing when I use my prompt. I tried to make it so the sound comes out of a part, and the sound wont work when I press the prompt. There is no errors in the output? When I moved the sound to the prompt, It worked, but I’m sure you all know probably don’t want the knock to be heard by everyone on the map when htere like 40 miles away.
Any way here is my code and Explorer tab if you can help me:

image

Thanks a bunch people!

2 Likes

You could possibly do this in a local script inside of StarterGui, that should work for making only the player hear the sound if the sound was inside the prompt. I’m not sure how to fix the sound not playing in another part but you could also have the sound in StarterGui.

2 Likes

Thanks for your reply, But It still doesn’t seem to work. Here’s my new script.

Is the Localscript located in Client?

1 Like

the .Triggered event on the proximity prompt has a player argument:

proximityPrompt.Triggered:Connect(function(playerWhoTriggered)
     print(playerWhoTriggered.Name)
end)

Try this and see what is prints, if it prints something the event works but the issue is with the sound.

local Object = workspace.Knock.KnockSoundSpawn.DoorKnockSound -- might be useful to add some WaitForChilds here to ensure the sound actually exists upon refrence 
local Prox = workspace.Knock.EToKnock 

Prox.Triggered:Connect(function()
	Object:Play() -- assuming object is what you want to play, it's probably easier to just refrence it here and play it. it looked like you were using a ancestry path to get to it before, which didn't seem to be leading anywhere.
end)

You used script .parent when it’s a local script inside the player. Change it to

workspace.Knock.KnockSoundSpawn.DoorKnockSound:Play()
1 Like

You could try making the sound local play:
ProximityPrompt.Triggered:Connect(function()
Object:Play()
end)
or putting plr inside the function

If you don’t want the knock to be heard by everyone 40 miles away, Then there is a property which you can change to determine how far the sound can travel.

Here

The higher the number, the longer distance the sound can travel.

2 Likes