Hello,
In my script, it is a biome music changer that changes the music based on biome.,
local r = {}
local new = false
local loopId = 0
script.Event.Event:Connect(function(s,vol,ye)
new = false
if #r~=#s then
new = true
else
for i=1,#r do
if new==false then
if r[i]==s[i] then
new = false
else
new = true
loopId = loopId + 1
end
end
end
end
if new==true then
r = s
loopId = loopId + 1
local id = loopId
if id ~= loopId then return end
while true do
for i = 1,#r do
if id ~= loopId then return end
script.Parent.ambience.SoundId = r[i]
if script.Parent.ambience.IsLoaded==false then
script.Parent.ambience.Loaded:Wait()
end
if ye==true then
script.Parent.ambience.Volume = 0
script.Parent.ambience:Play()
game:GetService("TweenService"):Create(script.Parent.ambience,TweenInfo.new(.5,Enum.EasingStyle.Quad),{Volume = vol}):Play()
print(script.Parent.ambience.TimeLength.." leng")
repeat wait() until script.Parent.ambience.TimePosition>=((script.Parent.ambience.TimeLength-script.Parent.ambience.TimePosition) * script.Parent.ambience.PlaybackSpeed)-0.5
print(tostring(script.Parent.ambience.TimeLength).." and "..tostring(script.Parent.ambience.TimePosition))
game:GetService("TweenService"):Create(script.Parent.ambience,TweenInfo.new(.5,Enum.EasingStyle.Quad),{Volume = 0}):Play()
script.Parent.ambience.Ended:Wait()
else
script.Parent.ambience.Volume = vol
script.Parent.ambience:Play()
print(script.Parent.ambience.TimeLength.." leng")
wait(((script.Parent.ambience.TimeLength-script.Parent.ambience.TimePosition) * script.Parent.ambience.PlaybackSpeed)-0.5)
print(script.Parent.ambience.TimeLength.." leng")
script.Parent.ambience.Ended:Wait()
end
print(script.Parent.ambience.TimeLength.." leng")
print(script.Parent.ambience.TimePosition.." pos")
if id ~= loopId then return end
end
end
end
end)
Expected:
Music plays and stops according to time length and playbackspeed, does not interrupt even if you swich between biomes back and forth
Reality:
If you switch between biomes back and forth, it will turn the volume to 0 during sound is playing.
It doesnât stop the sound, it just turns the volume to 0.
- Br, iSyriux