Boombox surround sound system

Regarding your edit to the topic:
You will find an easy solution to change which sound is playing by using the ProximityPrompt as I have demonstrated! I will add to my previous code to demonstrate.
You may achieve the desired effect, either by changing the soundId:

local ProximityPrompt = script.Parent.ProximityPrompt

local function TriggerPrompt()
	script.Parent.Menu.SoundId = "rbxassetid://1234567890"
end

ProximityPrompt.Triggered:Connect(TriggerPrompt)

Or by changing which sound instance it is playing at that moment:

local ProximityPrompt = script.Parent.ProximityPrompt

local sound1 = script.Parent.sound1
local sound2 = script.Parent.sound2

local function TriggerPrompt()
	if sound1.Playing then
		sound1:Stop()
		sound2:Play()
	elseif sound2.Playing then
		sound2:Stop()
		sound1:Play()
	end
end

ProximityPrompt.Triggered:Connect(TriggerPrompt)

Feel free to follow up with any questions. Anything you code inside the function connected to the ProximityPrompt’s trigger will run once any player triggers the ProximityPrompt, as long as it has been established in a ServerScript (The default, gray colored scripts).
Keep in mind that in the example provided above, the two conditions only run if one of the two songs are playing, if neither are, then nothing happens, but you can add a condition for that too!

If instead of this, what you actually want, is for a list of songs to be played automatically instead of just one, you could achieve that with code such as this:

local sound1 = script.Parent.sound1
local sound2 = script.Parent.sound2

while true do -- Using "while true do" results in an infinite loop. Using this without pauses or delays, such as task.wait, may crash studio due to excessive processing.
	sound1.Ended:Wait() -- This code assumes sound1 is already playing when the game starts.
	sound2:Play()
	sound2.Ended:Wait() -- Regarding crashes mentioned, this code waits until a sound has ended to continue running, and therefore should be fine.
	sound1:Play()
end

Remember, in this final example, you might want to use sound:Stop() if you set the “looped” property to enabled in any of the two sound instances, or disable the looped property completely, otherwise they may play overlapping!
Godspeed, Fellow Dev!

1 Like