Why does this crash storyboard? (randomize table

Hi,
I wrote some code outside of storyboard. Works without a hitch.
Now I want to copy it into storyboard. If I leave the following code in there:

math.randomseed(os.time())
local function table.shuffle(t)
– line 146
assert(t, “table.shuffle() expected a table, got nil”)
local iterations = #t
local j
for i = iterations, 2, -1 do
j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
table.shuffle(questions)

It crashes. If I leave it out it works.
it says it is missing a ‘(’ on line 146
:146: ‘(’ expected near ‘.’

Have no idea why. without storyboard it shuffles the tables nicely.
I just dumped all the code in the create scene event part to see what would happen. Would split it up if it worked there.
[import]uid: 100901 topic_id: 20817 reply_id: 320817[/import]

Now it is working :s
The local was giving problems.
math.randomseed(os.time())
function table.shuffle(t)

assert(t, “table.shuffle() expected a table, got nil”)
local iterations = #t
local j
for i = iterations, 2, -1 do
j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
table.shuffle(questions) [import]uid: 100901 topic_id: 20817 reply_id: 81926[/import]

Yes because you are adding a subfunction to a existing function. So calling function table.shuffle is local itself.

If you want to do it the other way you would have to name your function differently like

local function tableShuffle

[import]uid: 84637 topic_id: 20817 reply_id: 81931[/import]