generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Trying to make a "Typing" effect in a GUI

Previous Thread :: Next Thread 
konichiwah1337 is not online. konichiwah1337
Joined: 16 Sep 2013
Total Posts: 1979
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 is not online. 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
konichiwah1337 is not online. konichiwah1337
Joined: 16 Sep 2013
Total Posts: 1979
06 Dec 2015 09:12 PM
I got it down, but thanks anyway.


~ I am a lovely ROBLOX Developer ~
Report Abuse
littlelegomanon is not online. littlelegomanon
Joined: 07 Oct 2011
Total Posts: 146
07 Dec 2015 03:10 PM
Textbox.
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
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
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image