Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Typewriter animation only showing first letter?

I want to make a typewriter animation for my intro but it is only showing the first letter.

local introText = "Hello World!"
for i = 1, #introText do
	t_text.Text = string.sub(introText, 1, i)
	wait(0.5)
end

(Full Script)

-- Create Gui
local gui = Instance.new("ScreenGui",game.StarterGui)
local fillTop = Instance.new("Frame",gui)-- Fills in the little spot at the top of the screen
local back = Instance.new("Frame", gui)
local t_text = Instance.new("TextLabel",back)
-- Style Gui  
local bxSize = 1-- Make Background fill the whole screen
local bySize = 1
local bcr,bcg,bcb = .1, .7, 1-- RGB Color background 0 to 1
local fcr,fcg, fcb = bcr,bcg,bcb -- Same Color as background
local fxSize = 1
local fySize = .055
local fyPos = -.054
local txPos = .5
local tyPos = .5
local tcr,tcg,tcb = 255, 255, 255
local introText = "Hello World!"

-- Fill
fillTop.Size = UDim2.new(fxSize,0,fySize,0)
fillTop.Position = UDim2.new(0, 0, fyPos ,0)
fillTop.BackgroundColor3 = Color3.new(fcr, fcg, fcb)
-- Background
back.Size = UDim2.new(bxSize,0,bySize,0) 
back.BackgroundColor3 = Color3.new(bcr, bcg, bcb)
-- Text
t_text.Position = UDim2.new(txPos, 0 , tyPos, 0)
t_text.TextColor3 = Color3.new(tcr,tcg,tcb)
t_text.Font = "SourceSansLight"
t_text.TextScaled = true
t_text.BorderSizePixel = 0

-- Typewriter animation
for i = 1, #introText do
	t_text.Text = string.sub(introText, 1, i)
	wait(0.5)
	print(t_text.Text)
end

7 comments

0

Show me the introText.

0

its that variable. Its already in the code above

0

ok so I know it is looping and adding the text to t_text because I printed out t_text.Text and it updates but it is not updated the gui

0

I need to know the Intro's path (Parents)

0

its just one script. Is there a way I can send you the script?

0

yeah, I need to know this script's path, and the whole scripts you're mentioning. Edit there up.

0

Try using string.len(str) instead of the #, I'm not sure though.

1 answer

-- Create Gui
local gui = Instance.new("ScreenGui",game.StarterGui)
local fillTop = Instance.new("Frame",gui)-- Fills in the little spot at the top of the screen
local back = Instance.new("Frame", gui)
local t_text = Instance.new("TextLabel",back)
-- Style Gui  
local bxSize = 1-- Make Background fill the whole screen
local bySize = 1
local bcr,bcg,bcb = .1, .7, 1-- RGB Color background 0 to 1
local fcr,fcg, fcb = bcr,bcg,bcb -- Same Color as background
local fxSize = 1
local fySize = .055
local fyPos = -.054
local txPos = .5
local tyPos = .5
local tcr,tcg,tcb = 255, 255, 255
local introText = "Hello World!"

-- Fill
fillTop.Size = UDim2.new(fxSize,0,fySize,0)
fillTop.Position = UDim2.new(0, 0, fyPos ,0)
fillTop.BackgroundColor3 = Color3.new(fcr, fcg, fcb)
-- Background
back.Size = UDim2.new(bxSize,0,bySize,0) 
back.BackgroundColor3 = Color3.new(bcr, bcg, bcb)
-- Text
t_text.Position = UDim2.new(txPos, 0 , tyPos, 0)
t_text.TextColor3 = Color3.new(tcr,tcg,tcb)
t_text.Font = "SourceSansLight"
t_text.TextScaled = true
t_text.BorderSizePixel = 0

-- Typewriter animation
for i = 1, string.len(introText) do
    t_text.Text = tostring(string.sub(introText, 1, i))
    wait(0.5)
    print(t_text.Text)
end

2 comments

0

So your code kinda works. It is updating the text when I look at the explorer when testing the game but it is not actually updating it on the screen

0

btw, I'll give you a tip: Don't create the gui by the script, create it yourself, and then, in the script, simply change the visibility, and effects, but I suggest you to create guis, frames, texts, and everything on the studio, and not by scripting, because there's a big chance you made some errors...

This discussion is preserved as it was. New answers, comments, and votes are closed.