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):

local UserInputService = game:GetService("UserInputService");
local Players = game:GetService("Players");
local client = Players.LocalPlayer;
local text = string.format("Hello, %s.", client.Name);


UserInputService.InputBegan:Connect(function(input, gpe)
    if (gpe or not rawequal(input.KeyCode.Name, 'E')) then
        return;
    end

    for i = 1, #text do
        script.Parent.IntroText.Text = text:sub(1, i);
    wait(0.1);
    end
end);

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