Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there anyway to do this faster(Custom dialog gui) very slow?

I want to make a custom dialog (because the dialog of roblox is really bad) but it takes to long to make it (its a script in textlabel)

script.Parent.Text = "h"
wait(.1)
script.Parent.Text = "hi"
wait(.1)
script.Parent.Text = "hi T"
wait(.1)
script.Parent.Text = "hi Th"
wait(.1)
script.Parent.Text = "hi The"
wait(.1)
script.Parent.Text = "hi Ther"
wait(.1)
script.Parent.Text = "hi There"
wait(.1)
script.Parent.Text = "hi There :"
wait(.1)
script.Parent.Text = "hi There :D"

this way of changing the text of a textlabel takes to long is there anyway of doing this faster without just writing [script.Parent.Text = "hi There :D"]

3 comments

0

String Manipulation would be a better idea instead of this. I would suggest looking at the wiki.

0

wiki.roblox.com/index.php?title=String_manipulation&redirect=no

1

ty

2 answers

✓ Accepted answer
local text = "Hi There :D"

for i = 1, string.len(text) do
	wait(.1)
	script.Parent.Text = string.sub(text, 1, i)
end

2 comments

1

Can you explain this code.

0

i made an explained version

You can use string.gmatch

String.gmatch finds a certain part of a string, and switches each time. In your case, your string is trying to find every letter, and add it on to the sentence. You could iterate through every letter with a for loop using string.gmatch, and then add that on to the sentence. Here's how I would do your code. (You would use the "." string pattern aswell.)

local sentence=("") -- empty string
s = "hi There :D" --your sentence
for w in string.gmatch(s, ".") do --for loop through every character
	wait(0.1)
   	sentence=(sentence.. w)-- add the character to the sentence
	script.Parent.Text=sentence--change the text
end

I hope this helps.

2 comments

0

Honestly a simpler method would be to just use a numeric for loop. for i = 1, #str do script.Parent.Text = str:sub(1, i) wait() end

0

gmatch is overkill for this.

This discussion is preserved as it was. New answers, comments, and votes are closed.