Hey, I’m trying to make the current music being played on the client change when I enter a new area. So far, the area system works fine, I’m just having some trouble with changing the id of the sound being played.
sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://196346006"
sound.Parent = game.Soundscape
sound.Looped = true
SoundService:PlayLocalSound(sound) -- Play the sound locally
area.Changed:Connect(function(currentArea)
local serenitel = "rbxassetid://196346006"
local wilderness = "rbxassetid://189787632"
if currentArea == "Serenitel" then
sound:Stop()
sound.SoundId = serenitel
--sound.Looped = true
--SoundService:PlayLocalSound(sound) -- Play the sound locally
elseif currentArea == "Wilderness" then
sound:Stop()
sound.SoundId = wilderness
--sound.Looped = true
--sound:Play()
--SoundService:PlayLocalSound(sound) -- Play the sound locally
end
end)
This creates and plays the sound as soon as you enter the game. It plays the first id it’s set to, but then when the area is changed to “wilderness”, the id of the sound does not change, and instead, it creates a whole new sound, so now there are 2 different sounds being played at the same time.
How can I stop playing the 1st sound and start playing the 2nd one?