So basically, the texts types out itself (typewriting effect) and I want to add a keyboard key press sound to every letter that is typed. I have made the function but i am not sure if it is correct and I don’t now how to activate it properly. I am bad at scripting lol.
Make it a sound object in replicatedStorage, then place the sound id in the object and change the values you need.
local sound = game.ReplicatedStorage. -- Sound name
local soundClone = sound:Clone()
soundClone.Parent = -- if you want to play for everyone put it in workspace, if you want to play only near the person who plays the sound put it in there torso
soundClone:Play()
game.Debris:AddItem(soundClone, 1)
Oh okay, sorry if I was confusing, let me explain more,
When you create a sound object, you name it, to get it from replicatedStorage you need to call it by it’s name so *game.ReplicatedStorage.(Whatever you name the sound in replicatedStorage), yes you can delete all your code in that function and add that, Sound Objects | Documentation - Roblox Creator Hub if you scroll down in 3d sounds in the article it tells you how to add a sound object, then when your use .Parent that means where the sound is going to go, and the clone makes it so it does destroy the original sound, so it can keep on using it
Your putting the clone into the torso, so basically the script is copying the sound from replicatedStorage and is putting it in torso but not removing the original from replicatedstorage and then in one second the game.Debris will destroy the clone.
local Torso = Player.Character:WaitForChild(“Torso”) if your using r15 do HumanoidRootPart instead of torso, also looks like you have a syntax error, so try to find that place lol
Basically, it helps so you don’t have to use delay, and also if the object is destroy before :Destroy() goes off then it will respond with an error, unlike Debris which is smoother imo, but won’t cause the script to stop if the sound is not there