Pulling Word out of array fails

Hello,

so, I have an array with about 10.000 Words and I try to pull them out in a random order. But as soon as my index gets over around 2000 my script returns nil.

I tried out this solution:

return Array[index]

and a workaround:

for i, v in pairs(Array) do
    if i == index then
        return v
    end
end

Both of them did not work after a certain index is reached.

Any ideas how I could make this work without splitting the one array in multiple?

PS: I need the word almost instantly after request. I can’t allow any time over 1 sec for the word to be returned.

Maybe show entire function, huh?

I have nothing relevant to add. All things mentioned above have been tried in a Module script with same results.

How about if you printed index and before that print a table?
(For comparison, also print the data type of the index if it happens to be not a number)

Thanks for your reply!
Anyway, I figured, that the problem was actually the big size of my Array. The script didn’t manage to give me the word before it returned. As a result, it returned nil.

What?! How is that supposed to work? Size of an array doesn’t matter.

1 Like

I’m not shure either, but i testet both sizes and the smaller one works…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.