Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Quicker way for NPC type?

Asked by 6 years ago

I made a way to make NPC type that actually works, but to make it talk, I paste it as much times as the number of characters in the sentence, and then make it so after 0.05 seconds it types another character. Is there a faster way instead of removing a character from the text every time? (This is a LocalScript, so it can work with filteringenabled.)

01function onClick3(plr)
02    local text = plr.PlayerGui.TalkGui.Message3.TextLabel
03    text.Parent:TweenPosition(UDim2.new(0.3,0, 0.623,0),'Out', 'Quad', 0.23) -- gui pops up
04    wait(0.25)
05    sound:Play()  -- talking sound plays
06    text.Text = ""
07    wait(0.05)
08    text.Text = "D"
09    wait(0.05)
10    text.Text = "Do "
11    wait(0.05)
12    text.Text = "Do y"
13    wait(0.05)
14    text.Text = "Do yo"
15    wait(0.05)
View all 53 lines...
0
I give you a challenge: Make a function that accepts an argument that is any string, The function will take the string and display each character one by one, based on how long it is and how much type you make it delay. This could be fun! :D Pojoto 329 — 6y

2 answers

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

string.sub is what you'll need. string.sub(text, start, end) will return the part of the string from the start to end, or from the start to the end of the string - if the end parameter isn't specified.

1local txt = 'Do you like being classy?'
2 
3for i = 1, #txt do
4   text.Text = txt:sub(1, i)
5   wait()
6end

P.S: txt:sub(1, i) is syntactic sugar for string.sub(txt, 1, i)

Ad
Log in to vote
-1
Answered by 6 years ago

You can't do it :(

Answer this question