Posted 25 July 2017 - 04:00 AM
Hey,
So my code looks something like this:
But it keeps telling me this error:
"test:10: attempt to get length of nil"
What I'm trying to do is get the length of the strings in the table, printing out each character 1 by 1, but instead of doing that it errors on the first one, but then prints it out and then the rest? It's so weird, because 'k' is equal to 1 which is the first index of the table but it's like it's saying that I'm trying to get the length of the string of index 0, but it's clearly 1.
Why is this happening?
So my code looks something like this:
local t = {
"string",
"string2",
"string3"
}
local k = 1
while true do
for i=1,#t[k] do
print(string.sub(t[k],i,i))
end
sleep(0)
end
But it keeps telling me this error:
"test:10: attempt to get length of nil"
What I'm trying to do is get the length of the strings in the table, printing out each character 1 by 1, but instead of doing that it errors on the first one, but then prints it out and then the rest? It's so weird, because 'k' is equal to 1 which is the first index of the table but it's like it's saying that I'm trying to get the length of the string of index 0, but it's clearly 1.
Why is this happening?
Edited on 25 July 2017 - 04:26 AM