Can hear Audio from anywhere

Hello!

I am having an issue where I have an Audio in Workspace and a script in ServerScriptService, and it’s supposed to play a sound when you collect the coin which it does, but you can hear it wherever you are. If you’re about to say “Oh, just change the RollOffMaxDistance!” I have already tried that, and it still doesn’t affect it.

How can I fix this?

This is all that is necessary

game.Workspace.Folders._OTHERSFX.CoinCollect:Play()

If anyone knows, any help will be appreciated! :grinning_face_with_smiling_eyes:

4 Likes

Is it a local script? If not then thats why.

It’s just a script. Is that why?

Put the sound into the client, so StarterGUI, StarterPlayer, etc.

If it’s client sided, you will only hear it, but no one else will,
if it’s server sided (workspace, rep, serverstorage, etc) everyone will hear it, including you.

try this:

local Coin = game.Workspace.Coin
local Sound = game.StarterGUI.Sound

if Coin.Transparency == 1 then
   Sound:Play()
else
   Sound:Stop() -- in case it does start to play.
end)

Parent the sound inside the coin itself, parenting sounds in non BasePart objects(like folders) makes them global.

1 Like

Well the Coin is in ServerStorage because it spawns around the map, and I’ve tried that by when it is touched it plays the sound, but that didn’t seem to work.

The clone of the coin, needs to have the sound parented inside it’s BasePart and when somebody collects it, that specific sound plays(not the one in soundFX folder).

What do you mean? I put the Sound on the Coin Mesh which is the part that is being cloned.

Is the mesh a MeshPart? or a special mesh?

When making the coin, presuming it’s an instance.new then add audio to the coin and play it. If the sound is in a part the roll-off distance will work.

What do you mean exactly? Can you give an example?

image
It’s just a mesh. Basically a part

Oh okay I see, hmm I mean it should be working…

Are you playing the sound inside the coin? or workspace.Folders._OTHERSFX.CoinCollect?

I am just putting it where they’re telling me where to put it.

Well this is the script that I am doing

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		script.Parent.Sound:Play()
	end
end)
--when an event is going to be fired once, make sure to disconnect it right after
local connection
connection = script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		script.Parent.Sound:Play()
		--run code for collecting the coin here
		connection:Disconnect() 
	end
end)

I mean it just doesn’t seem to play at all when the sound is parented in that part, I assume because its in ServerStorage

Here is some useful information:

A sound is considered “global” if it is not parented to a BasePart or an Attachment . In this case, the sound will play at the same volume throughout the entire place.

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


The Touched event will only happen when outside of ServerStorage. If it isn’t playing but you’ve made sure the Play function is running (you could use a print statement to check), then check your sound settings. You might have set them super low when debugging the global sound problem.

So the script basically clones the coin that is in ServerStorage into Workspace, so it should work. This Script that is inside the Coin doesn’t seem to play it and doesn’t even give the print.

local coinclone = script.Parent
coinclone.Touched:Connect(function(HIT)
	script.Parent.Sound:Play()
	print("test")
end)