How do I add a sound to my typewriter effect?

A short overview of my problem:
I’m using the typewriter effect I found here. Now what I want to do is add a sound effect which plays when a letter is typed. Similar to how Tower Defense Simulator does it.

What I’ve tried to do:
Nothing honestly, I’m only imagining it, and since I’m a relatively new programmer I don’t know how I’m supposed to do it. The only rather explanatory thing I’ve thought of so far is calling a function which plays a sound whenever a letter is typed, but I don’t really know how to do that.

What I want:
Just toss me some ideas and link me to some useful resources you’ve found on this forum or somewhere else on the internet. I don’t need the actual script, I just want to grasp the concept and compile the things I’ve learned from this thread I made. Which i think is far more efficient.

(edited comment but i forgot to reply lol)

Each letter typed in will play a sound. If you know Undertale, then you probably know that I want to achieve the same dialogue thingy.

Oooh try this script then

local plr = game.Players.LocalPlayer.Name
local text = “type text here” – Geben Sie hier einen beliebigen Text ein

for i = 1, #Text do
script.Parent.Text = string.sub(Text, 1, i)
wait(0.06) – Zeit
end

Not like that, I have the script down already. I just need to be able to play a sound each letter typed in.

You can try this.

local text = “type text here”
local Sound = script.Parent.Sound

for i = 1, #Text do
script.Parent.Text = string.sub(Text, 1, I)
Sound:Play()
wait(0.06) – Zeit
end

1 Like

then you could just put the sound id into your script then

That’ll work I guess. I’ll see.
By the way, what’s with “- Zeit”?

I copy and pasted XINR0AH’s code, Zeit stands for time in German. If my code worked could you please mark it as a solution?

Am I supposed to need the module though?

Not necessarily if the code I’ve sent works just like you wanted it to be.

I can redefine the sound variable without any issues right?

Yeah you can redefine the sound variable.

It’s time in German

Okay, it worked. But I had to fix some of the code.