Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Do "Do-end" blocks count as functions? How about loops?

#My question Let's say you have something that requires a function such as a callback or coroutines. Would you hypothetically be able to use the following codes?

local a = 0
game.OnClose:connect(
do
print(a)
end)
local c = coroutine.create(while wait(1) a = a+1 do)

I do know that I can test this out myself but I'd like if I had a place where I can refer too if I forget next time, and I'd also love an explanation too. Plus other people who stumble upon this question can see the answer so they don't have to ask the same question.



Thanks!

1 answer

✓ Accepted answer

Blocks are not functions. A function is a type of object like a number or a string or a table. Loops and do-end blocks are not objects.

1 comment

0

The correct term is an "identifier" but close enough ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.