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

Help with strings?

Hey guys, I have lately been working on a admin script that makes a ScreenGui pop up on every player's screen and inside the gui is a Frame and a TextLabel that pops up with them, however I got all that solved out, but I don't just want the gui to suddenly appear outta no where with words on it... I want the words to be displayed on the TextLabel word from word and smoothly like if I say something like:

"#m Hello" On the screen it shows... 'H' wait(.2) 'He' wait(.2) 'Hel' wait(.2) 'Hell' wait(.2) 'Hello' it smoothly says all of that word from word. Don't worry I have tried already I am not just making a request. Here is the script I've worked on so far...

local player = game.Players.KingLoneCat
player.Chatted:connect(function(msg)
if msg:sub(1,3) == [[#m ]] then
local message = {msg:sub(4,300)}
local players = game.Players:GetChildren()
for i = 1, #players do
local screengui = Instance.new([[ScreenGui]], players[i].PlayerGui)
local frame = Instance.new([[Frame]],screengui)
frame.Size = UDim2.new(1,0,1,0)
frame.BackgroundColor3 = Color3.new(0,0,0)
frame.Transparency = .5
local tl = Instance.new([[TextLabel]],frame)
tl.Text = [[]]
tl.Size = UDim2.new(1,0,1,0)
tl.TextScaled = true
tl.BackgroundTransparency = 1
tl.BorderSizePixel = 0
tl.TextColor3 = Color3.new(.3,1,.25)
for q = 1, #message do
wait(.4)
for _,v in pairs(message) do
tl.Text = tl.Text..message[q]
print(v[q])
end
wait(5)
screengui:remove()
end
end
end
end)

Any help would be appreciated! Thank you :D

1 answer

✓ Accepted answer

You can use this function to do the "smooth typing". It uses string.sub to get the letters of the given string from the first to the second parameter. The second parameter iterates by one until it reaches the length of the string, so it replaces the old text with a new one incremented by one letter.

local function txt(gui,text)
	for i = 1,#text do
		gui.Text = string.sub(text,1,i)
		wait(.2)
	end
end

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