Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why does the Studio crash when I set up a 'for' loop like this? [Semi-Answered]

Asked by 9 years ago

Today, I was testing and creating a new code for an upcoming project, but, the whole studio crashed when I tested a specific for loop within the Commands Bar. I do not know why it crashes like this, but it crashes every time I run it. This is the code;

local Table = {
    "Player1",
    "Player2",
    "Player3"
}

for i, v in pairs, Table do
    print(i, v)
end

There's not much more I can explain sadly, only that it crashes when I use it. :(

-EDIT-

The purpose of why I coded the for loop like this was because I was curious on something; "I've seen 'for v in next, Table do', and 'for i, v in pairs (Table) do', so what happens if I set them up oppositely?" After setting up the code like this, it crashed when I ran it, thus my Question.

-EDIT2-

I just tested this code;

local Table = {
    "Player1",
    "Player2",
    "Player3"
}

for i, v in next (Table) do
    print(i, v)
end

But it only resulted in an error. Very interesting..

-EDIT3-

I took Smrt's Answer into account and used a wait function, and it returned function: 0EDC2EB8 table: 0EFAD730, repeatedly spamming it into the Output box. Why is this?

0
try doing in pairs (table) instead TheDeadlyPanther 2460 — 9y
0
@TheDeadlyPanther That's what I usually use. :P But my Question is 'why does this type of for loop crash the studio?' TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

I recommend you to add "wait ()"

0
Never crossed my mind to do that. XD Ok, I'll try and see what happens. :) TheeDeathCaster 2368 — 9y
0
Huh, that prevented crashing, but something came up in the Output: 'function: 0EDC2EB8 table: 0EFAD730'. This has been spamming since I fired the code. Do you know why it's sending this back? TheeDeathCaster 2368 — 9y
Ad

Answer this question