I was trying to make a 'press any key to continue' type of gui, where it will cycle through the next text when you press any key on your keyboard. But since I'm a noob at coding, I made something kind of terrible. Here is the script:

Script

Local Script Inside of a Text Label

--Variables--
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local TL = script.Parent
local Char = player.Character

--Services--
local InputService = game:GetService("UserInputService")


--Texts--
local text1 = "Hello "..Char.Name..", You are finally awake!"
local text2 = "You have been unconscious for a really long time"


--scripts--
InputService.InputBegan:Connect(function()
	for i = 1,#text1 do
		script.Parent.Text = string.sub(text1,1,i)
		wait()
	end
end)

InputService.InputBegan:Connect(function()
		if script.Parent.Text == text1 then
		for i = 1,#text2 do
		script.Parent.Text = string.sub(text2,1,i)
		wait()
		end
	end
end)

I know there is probably a better way of doing this. Can anyone help? Thanks.