Changing Sound TimePos Causes Static

Im doing some experiments with roblox sounds and I noticed that when changing timepos it causes a lot of static noises below is a example script


local audioPlayer = Instance.new("AudioPlayer")
audioPlayer.AssetId = "rbxassetid://9040512197"
audioPlayer.Looping = true
audioPlayer.Volume = 1
audioPlayer.Parent = Workspace

local deviceOutput = Instance.new("AudioDeviceOutput")
deviceOutput.Parent = Workspace

local wire = Instance.new("Wire")
wire.SourceInstance = audioPlayer
wire.TargetInstance = deviceOutput
wire.Parent = Workspace

while not audioPlayer.IsReady do
    task.wait()
end

audioPlayer:Play()

task.spawn(function()
    while true do
        if audioPlayer.IsReady then
            local newTime = math.random() * audioPlayer.TimeLength
            audioPlayer.TimePosition = newTime
        end
        task.wait(0.1)
    end
end)
1 Like