Hello, I have this script where it changes the fov based on PlaybackLoudness but it only works once and stops working after the next song plays. Ignore line 3 as thats for displaying the current song in a music player I have.
local randomTrack = availableMusic[math.random(1,#availableMusic)] currentTrack.Value = "..." wait(2) randomTrack:Play() local ScreenShakeSettings = { CameraMinFOV = 70, CameraMaxFOV = 90, CameraMaxVolume = 1200 } game:GetService("RunService").RenderStepped:connect(function() local CurrentLoudness = randomTrack.PlaybackLoudness local FOV = ScreenShakeSettings.CameraMinFOV + (ScreenShakeSettings.CameraMaxFOV - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume) if FOV > 0 and FOV < 130 then CurrentCamera.FieldOfView = FOV end end) currentTrack.Value = randomTrack.Name randomTrack.Ended:Wait() end
It's because you did not update the randomTrack value inside the function. That's why when the song ends, the function detects nothing from the song, but another song is still playing. You could try updating the randomTrack value inside the function.