|
| 06 Sep 2015 06:30 PM |
So, i want to make my own NPC chat system. I think i could do it.
I'm going to explain my idea, and see what you guys think... Basically, it'll be like when you play a video game and it says the NPC's name and then a box on the bottom of the screen. Each letter pops up slowly.
It would be a local script for the player who clicked on the NPC's head or whatever i choose to be clicked on. Then a screen GUI would pop up ONLY on their screen. Ever .1 second, a new letter would pop up. So like wait (0.1) script.Parent.Parent.Parent.ScreenGUI.TextBox.Text=("H") wait (0.1) script.Parent.Parent.Parent.ScreenGUI.TextBox.Text=("Hi") And so on. (After the function and stuff. But this seems like it could either cause lag, or it would just be plain inefficient. I'm still learning Lua, and i'm not really sure if my idea would work correctly... |
|
|
| Report Abuse |
|
|
Ortron
|
  |
| Joined: 19 Jul 2013 |
| Total Posts: 1297 |
|
|
| 06 Sep 2015 06:42 PM |
An easier way is using string.sub and string.len
String.len gives you a number value of how many letters there is in the string, here is an example
print(string.len('hello')) would print 5
String.sub makes a new string out of another when giving it a start and end point. The points must be number values, an example is here
print(string.sub('hello',2,4)) would print 'ell'
Using these you can make what you want in a for loop, like so
text=script.Parent.Text message="Hello World!"
for x=0,string.len(message) -- 0,12 text=string.sub(message,0,x) wait(.1) end
|
|
|
| Report Abuse |
|
|
Ortron
|
  |
| Joined: 19 Jul 2013 |
| Total Posts: 1297 |
|
|
| 06 Sep 2015 06:43 PM |
| Please excuse any mistakes, was written on a mobile |
|
|
| Report Abuse |
|
|
Ortron
|
  |
| Joined: 19 Jul 2013 |
| Total Posts: 1297 |
|
|
| 06 Sep 2015 06:44 PM |
For more on string.len and string.sub you can look at the wiki here
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.len
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.sub |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2015 06:46 PM |
| Thank you, i appreciate it! :) |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 10:14 AM |
More help? Its still my inefficient way, because i'm still trying to completely figure out this stuff...I've done a little research...and i got this...But its not really working...
ClickDetector.MouseClick:connect(function(click) local player = Workspace.Players[click.Name] player.PlayerGui.ScreenGui.NameBox.Visible = true player.PlayerGui.ScreenGui.DialogueBox.Visible = true player.PlayerGui.ScreenGui.NameBox.Text = "Name" player.PlayerGui.ScreenGui.DialogueBox.Text = "H" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi t" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi th" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi the" wait(0.1) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi ther" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there!" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! M" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My n" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My na" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My nam" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name i" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is N" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Na" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Nam" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Name" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Name!" end) |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 10:46 AM |
| Bump. Please help! I don't know why it didn't work...And i'm going to be using several of these NPCs and eventually they'll be choices that will then activate a different script and it will get pretty complicated. I just really hate the built in dialogue system... |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Sep 2015 02:16 PM |
| I am not great on scripting so can`t help, but would like to see what it looks like when it does work. Its a good idea |
|
|
| Report Abuse |
|
|
Kekodeko
|
  |
| Joined: 27 Jul 2015 |
| Total Posts: 1676 |
|
|
| 07 Sep 2015 02:19 PM |
^ Why would you even post that?! Go back to the off topic forum! |
|
|
| Report Abuse |
|
|
Ortron
|
  |
| Joined: 19 Jul 2013 |
| Total Posts: 1297 |
|
|
| 07 Sep 2015 04:06 PM |
Assuming you've defined ClickDetector
ClickDetector.MouseClick:connect(function(User) local player = User player.PlayerGui.ScreenGui.NameBox.Visible = true player.PlayerGui.ScreenGui.DialogueBox.Visible = true player.PlayerGui.ScreenGui.NameBox.Text = "Name" player.PlayerGui.ScreenGui.DialogueBox.Text = "H" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi t" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi th" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi the" wait(0.1) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi ther" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there!" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! M" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My n" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My na" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My nam" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name i" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is " wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is N" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Na" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Nam" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Name" wait(0.01) player.PlayerGui.ScreenGui.DialogueBox.Text = "Hi there! My name is Name!" end) |
|
|
| Report Abuse |
|
|
| |
|
Ortron
|
  |
| Joined: 19 Jul 2013 |
| Total Posts: 1297 |
|
|
| 07 Sep 2015 06:00 PM |
| If it doesnt work post the output here |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2015 08:19 PM |
| It worked! Thank you so much! It's really smooth, just inefficient! |
|
|
| Report Abuse |
|
|
|
| 12 Sep 2015 06:38 PM |
| Bump. Can i have some help making it more efficient...I'm literally ending up with lines and lines of just adding another letter and its getting seriously annoying. I'm not sure how exactly to make it 'efficient' though... |
|
|
| Report Abuse |
|
|