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

What's the difference between the first code and the second code?

Asked by 6 years ago

What's the difference when using "do"?

First code:

local words = "i failed in math class"
print(words)

Second code:

local words = "i failed in math class"

do
    print(words)
end

If it's useful, then how do I make it useful?

0
What is this post? Vain_p 78 — 6y
0
i agree DinozCreates 1070 — 6y
0
shouldn't it be obvious? other than the words printed fusionFSJAL 33 — 6y
2
There is no difference. Only that the latter is in a different scope. `do .. end` creates a new empty scope. User#24403 69 — 6y
0
ok fusionFSJAL 33 — 6y

1 answer

Log in to vote
1
Answered by
SpiralRBX 224 Moderation Voter
6 years ago
Edited 6 years ago

I suggest the first code shown. That saves time leaving more for actual development. Now if the code was

local words = game.Workspace.String.Value

do
    print(words)
end

then I suggest the second method.

If this helped don't hesitate to mark it as an answer.

0
Thanks <3 SpiralRBX 224 — 6y
Ad

Answer this question