so, i have a timer that whenever the time goes down, it makes a sound, but sometimes the sound doesnt really play correctly, i made a video so yall can see what i mean:
i did all the things u said in that post, but im still getting the same result shown in the video
this is how the script looks after i did the changes:
local ContentProvider = game:GetService("ContentProvider")
ContentProvider:PreloadAsync({sound})
while task.wait(.5) do
if not sound.IsLoaded then
sound.Loaded:Wait()
end
sound:Play()
end
again, the code is in a local script, so i dont know if that has something to do with it
Why are you doing all this waiting and sound loading within the loop?
The sound should be loaded into the workspace when the game is loaded, way before your timer is even activated.
In your timer script reference the workspace.sound at the beginning with a WaitForChild, then just play it when the timer runs out.
while task.wait(.5) do
sound:Play()
end
will just keep starting the sound every half second.
if timer == 0 then
sound:Play()
end
will work when the timer hits 0, and only play the sound 1 time.
I didnt say i wanted the sound to play when the timer hits 0, i want the sound to play when the times changes. The code i provided is just a test, but it is basically how my main script works, it plays when the timer changes
also all the loading stuff is just based on the replies that i’ve got in this post