So for the past few months, I have been grappling with functions such as string.sub, string.gsub, string.find, string.gfind, string.match,string.gmatch, and string.format, but never really understood them entirely, I have had some experience with string.sub, string.gsub, and string.find using patterns instead of the init string. For example, a couple months back, I tried making a typewriter gui using string.sub:
local text = "Some Demo Test"
local textlabel = script.parent
for i = 1, #text do
textlabel.Text = string.sub(text,1,i)
wait()
end
textlabel:Destroy()
and did some reseach on the lua users wiki, lua.org, and the roblox wiki for how to properly use these functions. Eariler today I tried experimenting with string.find and string.sub
local randomstring = "My Friend Chuck Says Hi"
print(string.sub(randomstring,2,5))--prints the 2nd, 3rd, 4th, and 5th letters of randomstring
local d = "%u+"
print(string.sub(randomstring,string.find(randomstring,d)))--prints first few uppercase letters
local d2 = "%w+"
print(string.sub(randomstring,string.find(randomstring,d2)).."---------d2")--prints the first chunk
local d3 = "%w+%s+"
print(string.sub(randomstring,string.find(randomstring,d3)).."---------d3")
but apart from those three, I really don't know much more about these functions that show up time and time again in scripts for admin commands, emotes through text, and etc. So if anyone can give me a good definition of what they do and an example of how they work, that would be much appreciated

1 comment
Even if this answer is very old, pairs is not an iterator function, but an iterator generator function. The pairs function is literally only 1 line of code,
return next, t, nil.