Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
10 years ago

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.

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. Tonitrua 20 — 10y
0
Yup. The closer you are to the brick the louder it will be. dyler3 1510 — 10y
0
Yes, but I would like it to be the same volume in the entire base without multiple blocks. Tonitrua 20 — 10y
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. dyler3 1510 — 10y
View all comments (6 more)
0
Thank you! Tonitrua 20 — 10y
0
No Prob, let me know if you need me to send an example, or if you get stuck. :P dyler3 1510 — 10y
0
I would actually like you to send an example please. If you could, that would be amazing. Tonitrua 20 — 10y
0
K. I'll update the post. dyler3 1510 — 10y
0
I have a problem. Whenever I spawn in the game, the sound stops. I reset and the sound will not play anymore. Tonitrua 20 — 10y
0
Is the sound set to 'looped'? dyler3 1510 — 10y
Ad

Answer this question