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

How do you have a key to change to different lines of text?

Asked by 5 years ago
Edited 5 years ago

I'm currently making an intro where you need to press 'E' to progress through the lines of text. The script also has some lines of code to make it have a typewriter effect. How do I add extras lines of code to change the text by pressing 'E'?

Current code (LocalScript):

01local UserInputService = game:GetService("UserInputService");
02local Players = game:GetService("Players");
03local client = Players.LocalPlayer;
04local text = string.format("Hello, %s.", client.Name);
05 
06 
07UserInputService.InputBegan:Connect(function(input, gpe)
08    if (gpe or not rawequal(input.KeyCode.Name, 'E')) then
09        return;
10    end
11 
12    for i = 1, #text do
13        script.Parent.IntroText.Text = text:sub(1, i);
14    wait(0.1);
15    end
16end);

Edit: The code above was changed but all I need to do now is know how to add more lines of text so that whenever someone presses 'E', it changes to the next line of text in chronological order.

Answer this question