Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Typewriter animation only showing first letter?

Asked by
tjtorin 172
6 years ago
Edited 6 years ago

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
0
Show me the introText. OfcPedroo 396 — 6y
0
its that variable. Its already in the code above tjtorin 172 — 6y
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 tjtorin 172 — 6y
0
I need to know the Intro's path (Parents) OfcPedroo 396 — 6y
View all comments (3 more)
0
its just one script. Is there a way I can send you the script? tjtorin 172 — 6y
0
yeah, I need to know this script's path, and the whole scripts you're mentioning. Edit there up. OfcPedroo 396 — 6y
0
Try using string.len(str) instead of the #, I'm not sure though. Eqicness 255 — 6y

1 answer

Log in to vote
0
Answered by
OfcPedroo 396 Moderation Voter
6 years ago
-- 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
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 tjtorin 172 — 6y
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... OfcPedroo 396 — 6y
Ad

Answer this question