Hello Everyone! I need help with this typewriter effect where I split the string of a username/display name
My Current Code (very aware this doesnt work, from an old project):
for i = 1,string.len("Display Name:") do
local letterofPlrDisplayName = string.sub(game.Players.LocalPlayer.DisplayName,i)
table.insert(displayNameSplit1,letterofPlrDisplayName)
end
If i’m correct, you can just set the text of the textlabel to whatever you want, and then do a script sort of like this:
local label = --your textLabel
local name = --player name or whatever text
for index = 1, string.len(textLabel) do
label.textTruncate += 1
task.wait(0.1) --effect time
end
Sorry if this has errors; I was making it pretty fast. Hopefully this should give you a basis.
For textTruncate, it should just completely cut off your text at the provided index
Edit: NOT textTruncate, the correct property is MaxVisibleGraphenes
I’ve created the effect in studio with this script:
local player = game.Players.LocalPlayer
local label = script.Parent.TextLabel
label.Text = player.Name
task.wait(5)
for index = 1, string.len(player.Name) do
label.MaxVisibleGraphemes += 1
task.wait(0.05)
end
Just so you know, the textLabel already has MaxVisibleGraphemes set to 0 and this is a LocalScript inside of the screenGui containing the textLabel in question.
displayname.Text = displayname.Text.." "..game.Players.LocalPlayer.DisplayName -- by default displayname is "Display Name:"
for i=1, (string.len(game.Players.LocalPlayer.DisplayName) + string.len("Display Name:")) do
displayname.MaxVisibleGraphemes += 1
task.wait(0.1)
end
results:
edit: yes, the max visible graphemes is set to 0
The issue is likely arising because of the gap between display name and the actual display name
It looks to be about 2 spaces long, which is the same number of characters that the typewriter is off by.
Try this code instead:
displayname.Text = "Display Name: " ..game.Players.LocalPlayer.DisplayName -- by default displayname is "Display Name:"
for i=1, #displayname.Text do
displayname.MaxVisibleGraphemes = i
task.wait(0.1)
end
It’s very similar to what Mr_Spokes has been doing, but just written slightly differently to prevent issues.
local text = "Display Name: "..game.Players.LocalPlayer.DisplayName
local current = ""
for i = 1, text:len() do
local letter = text:sub(i, i)
current ..= letter
print(current)
task.wait(1)
end