Playing same sound sometimes don’t work

I have a spin wheel, and it will spin faster and faster over time and then stop. for each “tick”, it will play a sound, so the sound is playing more and more frequently

sometimes the sound would play for the first couple of ticks, but then it doesn’t play at all for the rest of the ticks

local function Spin()
  local waitTime = 0.4
  local sound = script:WaitForChild(“TickSound”)
  for i = 1 to 20 do
    -- rotate wheel one sector
    sound:Play()
    task.wait(waitTime)
    waitTime *= 0.9
  end
end

What might be the problem and how may I fix that?

snip

for i = 1, 20 do
	spawn(function()
		sound:Play()
	end)
1 Like

the sound may be playing too many times too quickly. after 10 spins it would be playing every 0.1 seconds. you could try duplicating the sound, then playing it and deleting it afterwards

would look like this

local function Spin()
  local waitTime = 0.4
  local sound = script:WaitForChild(“TickSound”)
  for i = 1 to 20 do
    -- rotate wheel one sector

    local newSound = sound:Clone()
    newSound.Parent = sound.Parent
    newSound:Play()

    game.Debris:AddItem(newSound, 1)

    task.wait(waitTime)
    waitTime *= 0.9
  end
end
1 Like

thanks for suggesting. I tried and this doesn’t solve the problem though.

thanks for suggestion. I tried a slightly different approach

local newSound = sound:Clone()
newSound.Parent = workspace
newSound.PlayOnRemove = true
game:GetService("Debris"):AddItem(newSound, 0)

It should work like yours except the sound will not cut off after 1 sec

oh yeah, that works too, also instead of using debris and removing it 0 seconds later, why dont u just use :Destroy()?

oh it is a silly habit. Destroy() should work the same

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.