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

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

Asked by 8 years ago
Edited 8 years ago
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?

0
Do you want 3D sound? User#5423 17 — 8y
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. Scancilen 15 — 8y
0
Code block your code. Press the blue lua button and paste the code in the "~~~~" alphawolvess 1784 — 8y
0
I still need help.. Scancilen 15 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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!

Ad
Log in to vote
0
Answered by
Valatos 166
8 years ago
Edited 8 years ago

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!

Answer this question