Need help understanding Luau

Hi. I just noticed a post talking about Luau. My questions are:

  • Was this on roblox before?
  • What’s the difference between Lua and Luau?
  • Could someone explain the syntax?

Thanks!

2 Likes

Luau is basically “roblox lua”
Luau has certain features that vanilla lua doesn’t have, you can look in #updates:announcements and see posts regarding luau updates.

1 Like

I’ve never saw a colon in Lua besides function calls like SUS:AMOGUS()

What does this do

local no_returns: (number, string) -> ()
local returns_boolean_and_string: (number, string) -> (boolean, string)

function foo(x: number, y: number): (number, string)
    return x + y, tostring(x) .. tostring(y)
end

The stuff after the colon basically means what datatype the variable can be. The parentheses means parameters or return variables.

This function takes in 2 numbers: x and y. It returns a number and a string.

1 Like

So, it’s basically like C# but low budget? :smiley:

C# and lua are completely different, I wouldn’t compare them to each other

Also, how is this useful? I can just type

function foo(x, y)
    return x + y, tostring(x) .. tostring(y)
end

and it does the exact same thing.

I guess you can compare them but they have there differences, I wouldn’t call lua low budget

2 Likes

It’s just used for type-checking. If you insert --!strict at the top of a script, the luau type-checker can show type-related warnings in script analysis. It won’t throw errors as a direct result from type mismatch, though.