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

How am I supposed to let music play in one area?

local s = Instance.new("Sound")

s.Name = "BGMusic" s.SoundId = "http://www.roblox.com/asset/?id=180804241" s.Volume = 1 s.Looped = true s.archivable = false

s.Parent = game.Workspace

wait(0)

s:play()

When I try to put music in my game, and then put other music for another spot, it plays at the same time and I can hear both of the audios for the different places at the same time. So now, I am trying to find out how to make the music just play in a certain section and in a other section it plays other music besides the other area.

Am I doing something wrong, Or is the script broken-ish?

4 comments

0

Do you want 3D sound?

0

If you mean 3D As in the entire game can hear it, then no. I just want a certain audio played in one area, and a different in a other.

0

Code block your code. Press the blue lua button and paste the code in the "~~~~"

0

I still need help..

2 answers

Hello. In order to do this,you would need to use LOCAL music.You can easily do this by placing a sound inside a ScreenGUI,and adding a LocalScript to it.

Something along the lines of

local SomeSound=script.Parent.Sound
game.Workspace.Area1.Touched:connect(function(h)
if game.Players:GetPlayerFromCharacter(h.Parent)~=nil then
SomeSound:Stop()
SomeSound.SoundId="rbxassetid://183003997"
wait(0.1) --For some reason,sound glitches and doesn't stop if a wait() isn't called after an ID change.
SomeSound:Play()
end
end)

You would use an event that is fired in the server and received in the client to switch the song/sound that the local sound is playing.

If you want a 3D sound,you would need to use FilteringEnabled and add it to the Workspace from a localscript,therefore making it local to you. Parenting the sound to a brick inside the CurrentCamera might work;I am unsure of it.

Hope this information helps!

This is simple put a brick, place a sound in it, and set the MaxDistance and MinDistance, if you test it it should only play if within the set ranges

Note: you will still need to set ID and set it to play!

Hope i helped!

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