|
| 06 Dec 2015 08:06 PM |
For example, someone typing a sentence using a Keyboard. I'm trying to mimic that but I've never done it before, this is my best guess.
Also, to put it in perspective, think about an RPG and when the NPC's talk to you.
This script is for an NPC GUI. When you press a "Chat" button it will greet you with the following script using a 'typing' scheme.
script.Parent.MouseButton1Down:connect(function() local text = script.Parent.Parent.Parent.npcChat.ImageLabel.TextLabel.Text local txtTable = { "t", "e", "s", "t", } text = table.concat(txtTable, ' ') end)
~ I am a lovely ROBLOX Developer ~ |
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
|
| 06 Dec 2015 08:10 PM |
function slowtype(label,text,time) for i=1,string.len(text) do label.Text=label.Text .. text[i] wait( time/string.len(text) ) end end
script.Parent.MouseButton1Down:connect(function() local text = script.Parent.Parent.Parent.npcChat.ImageLabel.TextLabel local message = "rofl" slowtype(text,message,1) end)
--something like this? |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 09:12 PM |
I got it down, but thanks anyway.
~ I am a lovely ROBLOX Developer ~ |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Dec 2015 03:17 PM |
Hello!! I was wondering,
function slowtype(label,text,time) for i=1,string.len(text) do label.Text=label.Text .. text[i] --What does this do?? label.Text .. text[i]???? wait( time/string.len(text) ) end end |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2015 03:26 PM |
.. is called the string concatenation operator.
It's a binary operator (In this context, that means it cares about it's left and right hand sides) which takes two strings (Or e.x. a string and a number and it'd convert the latter) and puts them together.
The label text presumably starts as the empty string -- ""
You may know that (string)[i] will return the i-th character/letter of the string.
So the first time around, i will be 1 and it will be "" .. (first letter)
The second time around i will be 2 and it will be "(first letter)" .. (second letter)
Third time, i will be 3 and it will be "(first letter)(second letter)" .. (third letter)
You can probably see where this is going now :P |
|
|
| Report Abuse |
|
|