my script is below, the pitch wont change even though i’ve set it to change
local playlist = {
"rbxassetid://124331719259335",
"rbxassetid://118669777510137",
"rbxassetid://102516975408634"
}
local currentSongIndex = 1
local fadeDuration = 2
local isPaused = false
local function fadeOut(audio)
local startTime = tick()
local startVolume = audio.Volume
while tick() - startTime < fadeDuration do
audio.Volume = startVolume - (startVolume * (tick() - startTime) / fadeDuration)
wait(0.1)
end
audio.Volume = 0
audio:Stop()
end
local function fadeIn(audio)
local startTime = tick()
local startVolume = 0
audio.Volume = startVolume
while tick() - startTime < fadeDuration do
audio.Volume = startVolume + (1 * (tick() - startTime) / fadeDuration)
wait(0.1)
end
audio.Volume = 1
audio:Play()
end
local function playNextSong()
for _, audio in pairs(audioFolder:GetChildren()) do
if audio:IsA("Sound") then
audio:Stop()
end
end
local songId = playlist[currentSongIndex]
for _, audio in pairs(audioFolder:GetChildren()) do
if audio:IsA("Sound") then
audio.SoundId = songId
audio.Pitch = 0.35
wait(0.1)
audio:Play()
end
end
currentSongIndex = currentSongIndex + 1
if currentSongIndex > #playlist then
currentSongIndex = 1
end
end
local function pauseMusic()
if isPaused then return end
isPaused = true
for _, audio in pairs(audioFolder:GetChildren()) do
if audio:IsA("Sound") then
fadeOut(audio)
end
end
end
local function resumeMusic()
if not isPaused then return end
isPaused = false
for _, audio in pairs(audioFolder:GetChildren()) do
if audio:IsA("Sound") then
fadeIn(audio)
end
end
end
playNextSong()
for _, audio in pairs(audioFolder:GetChildren()) do
if audio:IsA("Sound") then
audio.Ended:Connect(function()
playNextSong()
end)
end
end
game.ReplicatedStorage:WaitForChild("PauseCommand").OnInvoke = function()
pauseMusic()
end
game.ReplicatedStorage:WaitForChild("ResumeCommand").OnInvoke = function()
resumeMusic()
end