Help needed with playing a sound every time a letter is written

Hello there!

I’m currently making a debating game inspired by Phoenix Wright (all original assets of course!)
however, what i need is a beep sound to play whenever a letter is written onto the GUI like this
Problem is, it only plays the sound on the first word, and then stops completely.
Below is the script i’m using to make a typewriter effect

local Beep = game.ReplicatedStorage["Beep!"]
local playerObjection = game.Workspace.playerObjection
playerObjection = false

wait(1)

local playerText = {
	
	"Hello",
	"I am here to debate the following topic!",
	"Should developers be allowed to DevEx...",
	"For less?"
}
local textDisplay = script.Parent

local function typewrite(object, text)
	for i = 1, #text, 1 do
        Beep:Play()
		object.Text = string.sub(text, 1, i)
		wait(0.05)
	end
end

for i, v in pairs(playerText) do
	typewrite(textDisplay, v)
	wait(3)
end

Any help would be appreciated

Is it playing on only the first word or only the first letter? That might help me understand your issue.

Seems to be the first word

charssss

Not sure if this would fix your issue, but I think you should move the sound to Workspace instead of ReplicatedStorage

Also, I would add this to the typewrite function:

local function typewrite(object, text)
	for i = 1, #text, 1 do
        Beep:Play()
		object.Text = string.sub(text, 1, i)
		wait(0.05)
        Beep:Stop() -- add this
    
	end
end

Try:

in function typewrite do

Beep:Play()
Object.Text = Text
wait(0.05)
Beep:Stop()

could be a roblox error

Nope. does the exact same apart from now playing on the first word of the first sentence and the first word of the last sentence…

I think it might be an issue with the sound you are using. I tested this with a different sound and it worked perfectly.

1 Like

Ah well, it appears so. a rather sad way for 20 robux to go.

But thanks for the help! :slight_smile:

I tested this myself and I seem to be getting different results depending on which Audio I try. I noticed that if your audios TimePosition is set to anything but 0, say over the audios length, the next word, it will glitch / not play. So keep the code you have but set the TimePosition property in the Sound Instance to 0 and see if that works? (Worked for me.)

considering the original audio was 0.17777 (recurring) seconds, i’m starting to think that its probably to quick of an audio, since my time position is always set at 0

I’ve replicated and tested everything in your LocalScript, even with a faster beep sound and even placing it in a TextBox, child to a Frame, child to a StarterGUI.

It works absolutely fine for me, so I’m unsure what could be wrong? How about I send you a replica of of the working version?

If this doesn’t work, then something must be wrong with your Studio or Roblox:
for_cool_kid.rbxl (25.8 KB)

1 Like

Thanks! I’ll be sure to check it out as soon as i can