So I have a String value in ReplicatedStorage. The goal is to update the gui and make it say the string value. I'm trying to make it like it is typing the value by itself. This is the code I have but It is only printing one letter everytime the string value changes.
local status = game.ReplicatedStorage:WaitForChild("StatVal") function statUpdate() local val = status.Value local letter = nil for i = 0,string.len(val) do letter = string.sub(val,i,i) script.Parent.Text = letter end end status.Changed:Connect(statUpdate)
String indexes begin at 1. We also have the #
operator in Lua, which can tell us the number of bytes in a string.
for i = 1, #val do local letter = val:sub(i, i) script.Parent.Text = script.Parent.Text .. letter end
You're setting the text to the new letter, but we want to use the ..
concatenation operator to create a new string, made by glueing one string to another.