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')
In your Module, you are expecting Message to be a string and TextLabel at the same time, which simply isn’t possible . 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
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 - #8 by WoolHat
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