Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a sound play in one area only?

Everytime that I make my character teleport away, the sound is still playing.

Also, when I try to stop the sound for myself, the sound gets deleted and no one can hear it.

1 answer

✓ Accepted answer

Insert a script into a local script, put it in the startergui, and try something like this.

local Player=game.Players.LocalPlayer
Song=game.Workspace.Sound:clone()
function Touched()
	if Player.PlayerGui:FindFirstChild("Sound")==nil then
		Song.Parent=Player.PlayerGui
		Song.Volume=2
		Song:Play()
		Song.Looped=true --set this to true or false--
	end
end

function TouchedE()
	if Player.PlayerGui:FindFirstChild("Sound")~=nil then
		Player.PlayerGui:FindFirstChild("Sound"):remove()
	end
end

--Change 'Part' to the name of the brick touched.
game.Workspace.Part.Touched:connect(Touched)
game.Workspace.Part.TouchEnded:connect(TouchedE)

Hopefully this'll work. It should if you do what It says.

10 comments

0

Will it play in that general area? It is a big base with alarms blaring and I want the sound to only play in the entire place.

0

Yup. The closer you are to the brick the louder it will be.

0

Yes, but I would like it to be the same volume in the entire base without multiple blocks.

0

Hmm...that'd be harder to do...you would probably need to insert a brick that fills the building and make it so that when the player touches it, the song gets inserted into their playergui. When they're not touching it, the sound is removed from their playergui.

0

Thank you!

0

No Prob, let me know if you need me to send an example, or if you get stuck. :P

0

I would actually like you to send an example please. If you could, that would be amazing.

0

K. I'll update the post.

0

I have a problem. Whenever I spawn in the game, the sound stops. I reset and the sound will not play anymore.

0

Is the sound set to 'looped'?

This discussion is preserved as it was. New answers, comments, and votes are closed.