How to create animating text?

how do we create text that one letter appears every second? nothing is working because i pasted in the function

Module

local w = {}


function w.WriteLine(Message, Title)
	for i = 1,#Message,1 do
		wait(0.05)
		Message.Text = string.sub(Message,1,i)
	end
end



return w

Local Client

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local ModuleScripts = Modules:WaitForChild('ModuleScripts')

local LineWriter = require(ModuleScripts:WaitForChild('LineWriter'))

LineWriter.WriteLine('This is your first message, write it down here')
1 Like

If you want it to make a letter every second you can change the wait(0.05) to wait(1).

no the code isnt working 30charactrer

Is there an error? You have to explain what about the code isn’t working.

It looks like you’re trying to use string operations on the label (Message) instead of its text (Message.Text) on both of these lines.

1 Like

In your Module, you are expecting Message to be a string and TextLabel at the same time, which simply isn’t possible :sweat_smile:. You should write the function w.WriteLine again, but with perhaps some better argument names so that it’s easier to distinguish what is what :slight_smile:

Here's what you did
function w.WriteLine(Message, Title)
    -- "Message" is a string, "Title" is not used
    
	for i = 1,#Message,1 do
		wait(0.05)
		-- You're attempting to update the property "Text" of "Message",
		-- which doesn't exist. You also use string.sub(Message) on a TextLabel,
		-- which doesn't work either. We see what you're trying to do, though
                -- so that's cool!
		Message.Text = string.sub(Message,1,i)
	end
end

For example:

-- // Added "delay", it might come in handy ;)
function w.WriteLine (textLabel, text, delay)
    for index = 1, #text do
        textLabel.Text = text:sub(1, index);
        wait(delay);
    end
end

But, this function may “fail” in the future if you’re attempting to update the text label while something else is already doing it, check out this thread for a proper method: Halting a text writing mechanism

1 Like

amma good with this? no?

local w = {}

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local StoryMenu = PlayerGui.MainGui.Main:WaitForChild('StoryMenu')
local Backpack = PlayerGui.MainGui.Main:WaitForChild('Backpack')


local function SetUpStoryBoard(visi)
	if visi then
		StoryMenu:TweenPosition(UDim2.new(0.5, 0,1, 0), 'InOut', 'Sine', 0.2)
		Backpack:TweenPosition(UDim2.new(0.499, 0,1.11, 0), 'Out', 'Quad', .1)
	end
	if not visi then
		StoryMenu:TweenPosition(UDim2.new(0.5, 0,1.127, 0), 'Out', 'Sine', 0.2)
		Backpack:TweenPosition(UDim2.new(0.499, 0,1, 0), 'Out', 'Quad', .1)
	end
end



function w.WriteLine(title, text, delay)
	SetUpStoryBoard(true)
	StoryMenu.Title.Text = title
    for index = 1, #text do
       StoryMenu.Message.Text = text:sub(1, index)
        wait(delay)
    end
   wait(1)
   SetUpStoryBoard(false)
end



return w



1 Like