Typewrite Talk Sound Producing Crackling Audio

I have a script that “typewrites” text in a dialogue box, and I have a sound play for every letter except if its a space. I noticed that because of that, the audio that is played back to back has this crackling/popping sound. Is there any way to fix this? The audio itself is not the issue, the beginning and end of the audio are faded in and out, so it should not produce popping sounds.

local function typewrite(object, text, length)
	local stoptext = false
		stoptext = true
	for i = 1, #text, 1 do
		object.Text = string.sub(text,1,i)
		if string.sub(text,i,i) ~= " " then
			if gui.TalkSound.IsPlaying then
			gui.TalkSound:Play() -- where talksound plays
		if stoptext == true then
			break -- will not continue if interrupted to prevent text glitching
		wait(length) -- time between letters

Try playing with volume instead of :Stop

When there is a space, make it volume 0, when its back to normal make it volume 5 or something and when the typing is finished make it :Stop

correct me if this is not the issue

I had the :Stop there so the sound could repeat smoothly. Sometimes without using the Stop function, the sound will just not play. adding that helped. But for the sake of trying it I’ll try it out real quick just to see.

1 Like

Make it wait? maybe the audio is overplaying


This usually means that you’re playing the ‘Sound’ object too frequently.
if not Sound.IsPlaying then Sound:Play() end

1 Like