So I ran into a dilemma, when I was working on this interaction system I got to the point where I want to display the message from the beginning to the end character.
e.g
message = "Hello, my name is bob"
-- Display on a gui from "Hello" to "bob"
Can someone break it down from the beginning so I know how to script this?
local message = "Hello, my name is bob"
local text = ""
for i = 1, #message do -- runs to the length of the string
wait(0.04) -- so its not instant
text = string.sub(message, 1, i) -- string.sub(string s, start, end), i will continuously increase until it reaches the end of the string
print(text) -- print it in the output, or do whatever you want to do with it
end
local XPos = 0
local YPos = 0
function typeLetter(Letter)
local TL = script:WaitForChild("Letter"):Clone()
TL.Text = Letter
TL.Position = UDim2.new(XPos, 0, YPos - 0.1, 0)
TL.Parent = script.Parent:WaitForChild("DescFrame")
TL:TweenPosition(UDim2.new(XPos,0,YPos,0),"Out", "Quad", .1, true)
XPos = XPos + .025
if XPos > .95 then
YPos = YPos + .4
XPos = 0
end
if Letter == "." or Letter == "!" or Letter == "?" then
wait(.5)
end
end
local Message = "Come back when you're done."
local text = ""
for i = 1, #Message do -- runs to the length of the string
wait(0.04) -- so its not instant
text = string.sub(Message, i, i)
typeLetter(text)
end
So this is my first time making a typewriter script. I decided to do it a little bit differently, because I saw a pretty cool reference. The texts kind of overlap eachother a bit. Anyone know a fix to this?
Yeah, the problem isn’t knowing what it is though. I just don’t know what to do, because I’ve never done this before. I searched up textsize, but that didn’t help. It always turns out like this.