Script editor highlights # as comment like Python

When you start the script with #, everything after it is highlighted as if it were a comment.

image

Btw the code won’t get underlined when it’s not even valid syntax, but the # does get underlined.

That snippet should reproduce the bug. (and no it doesn’t actually work lol)

# Python is supported in Roblox confirmed!!!!!

def foo():
    print("smh") -- Additionally, when pressing enter, indentation is preserved.
    print("assuming you press enter this line will be indented")
foo()
2 Likes

That’s because starting a script with # is valid syntax in Lua, and it does indeed act as a comment line. It’s to allow you to use the shebang syntax to make a .lua file executable with a particular shell command.

Try making a .lua file starting with a # line and executing it from the command line on your desktop and you’ll see that it’s valid syntax.

2 Likes

oh wow I didn’t know that. But I don’t think this is useful/possible in roblox?

1 Like

Indeed it’s not possible in Roblox. Not saying that this isn’t buggy behavior given that it highlights but then doesn’t work, just giving you context on why this exists in the first place.

1 Like

Technically it’s not valid syntax. However, Lua’s implementation of loadfile skips over it for convenience. This behavior is reflected in some syntax highlighters, such as Scintilla, which is why it’s present on Roblox.