Hello, i’m trying to create a typewriting effect, and I mostly got all the main components done, I just need to insert this sound while the typing effect is going on, here is the sound id: 151715959
The sound is just one click, but what I want to do is make it so it sounds like you’re typing as the sound is being played. So essentially the sound is supposed to keep repeating until the typewriting effect ends, but I don’t want there to be a noticeable gap in between sound looping. Could someone please help? Here is my current script:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local TriggerPart = workspace:WaitForChild(“TriggerPart”)
local Frame = script.Parent.Parent
local typewritingTriggered = {}
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
wait(0.05) – Adjust the wait time to make typing faster
end
end
TriggerPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not typewritingTriggered[player] then
typewritingTriggered[player] = true
Frame.Visible = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
AutoType(script.Parent, "TEST TEXT 123")
wait(#"hello hi" * 0.05) -- Adjust the wait time here too
Frame.Visible = false
wait(0)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
wait(0.05) – Adjust the wait time to make typing faster
end
end
Insert a sound:Play() here
I dont know how to script, I tried it with an AI and it got it all messed up
First, I do not recommend getting an AI to modify code for you, because 90% of the time it will almost never work.
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
wait(0.05) – Adjust the wait time to make typing faster
YourSound:Play() -- Sound here
end
end
I want to make it so the sound is repeatedly played until the typing effect ends, because my sound I have is only one singular click. Do you know how I could approach that?
Thank you so much
it should repeatedly play until the loop is done.
I replaced my lines of code with the code you sent me but it completely messed it up, now the typewriting effect isn’t even working
please define your sound object first
local YourSound = -- where the sound object is located
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
wait(0.05) – Adjust the wait time to make typing faster
YourSound:Play() -- Sound here
end
end
How do I define it? please help
sigh alright
where is your sound located? please provide a picture
my sound is located in workspace
then do something like workspace.Sound
So, the easiest way to do this would just be parenting the sound you want to play (as an actual audio/sound object) and put it in the script the type function is being called from. Then within the for, i loop, do script.Sound:Play() and this should work. This should only play it for the player for whom it is typing for as well, which should prevent other players from hearing it as well.
uh no. local variables are to easily access certain objects and shorten code. also SoundId is a property inside of “Sound”
so should I keep the sound in workspace or do I parent it to the script
your choice. i’d put it in the script though
local Sound = script.Sound
do i need to adjust the script after i parent it
there is no need, because all you’re doing is parenting an object inside of it
parent the sound to the script, and the easiest way to implement it afterwards would be to do something like this:
function AutoType(textLabel, message)
for i = 1, #message do
textLabel.Text = string.sub(message, 1, i)
wait(0.05) – Adjust the wait time to make typing faster
script.Sound:Play() -- after the script and dot, type the sound name to match whatever you named it
end
end
2 Likes