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

Something goes wrong when i try to use string.sub?

Everytime i try to make a script like

local text = "blah blah blah"
for i = 1,#text do
	game.ReplicatedStorage:WaitForChild("StringValue").Value = string.sub(#text,1,i)
	wait()
end

the value only says a random number, such as "32","35","11", etc..

please help!

1 answer

✓ Accepted answer

When you use "#", Lua reiceves a number, what when we are talking about a table or a string it means it's lenght, so you need to do the same thing whitout the "#" in string.sub's first argument, how like this:

--> made by Convexyz!

-- Variables --
	
str = "blah blah blah";

for i = 1, #str do

print(string.sub(str, 1, i));

end

2 comments

0

got it @lunatic_o ! thank you :D

0

No problem, marking the question as answered will be appreciated!

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