Menu
CoddyTech
Course

Luau for GDScript Developers

Bring GDScript experience to general Luau: truth and capture rules, typed signatures, table collections, CLI modules and metatable objects. Build a stock ledger and port inventory and reservation programs.

GDScript and Luau side by side

The same program in GDScript and in Luau, from the lessons of this course.

  1. Print and Comment

    GDScript print concatenates its arguments without the same separators as Luau print. The source explicitly includes spaces and punctuation. Use a single constructed Luau string for exact output; comments change from # to --.

    GDScript
    1extends SceneTree2func _init():3    var name = "Ada"4    print("Hi ", name, "!")5    quit()
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. Null and Missing Fields

    A GDScript Dictionary can retain a key with null as its value. A Luau field assigned nil disappears. Port both the presence check and the value check when these are separate decisions.

    GDScript
    1extends SceneTree2func _init():3    var data = {"seats": null}4    print(data["seats"] == null)5    print(data.has("seats"))6    quit()
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. Ranges to Inclusive Loops

    GDScript for traverses iterable values and range excludes its stop value. Luau numeric for includes its limit. Translate the bound explicitly; a list of values and a numeric counter are different loop forms.

    GDScript
    1extends SceneTree2func _init():3    var values = [2, 4]4    for value in values:5        prints(value)6    for n in range(3):7        print(n)8    quit()
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. Functions and Returns

    A GDScript function that mutates an Array affects the caller even if it returns no useful result. Luau table arguments also carry references. Rebinding a parameter and mutating the referred collection are distinct operations.

    GDScript
    1extends SceneTree2func add_item(items):3    items.append(9)4func _init():5    var items = [1]6    add_item(items)7    print(items.size())8    quit()
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. Lists as Dense Tables

    GDScript Array uses zero-based indexes and append. Luau sequences are dense one-based tables with table.insert. A typed sequence description does not make those indexing conventions interchangeable.

    GDScript
    1extends SceneTree2func _init():3    var items = [4, 8]4    items.append(12)5    print(items[-1])6    quit()
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. Sorting and Comparators

    GDScript sort_custom accepts a Boolean ordering callback. Luau table.sort also needs a strict Boolean comparator. Keep equal-primary-key tie handling explicit so output order does not depend on unspecified stability.

    GDScript
    1extends SceneTree2func _init():3    var words = ["pear", "fig", "plum"]4    var kept = words.filter(func(w): return w.length() >= 4)5    kept.sort()6    print(" ".join(kept))7    quit()
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final GDScript Ports

2 lessons

More courses for GDScript developers

Learn Luau from another language

Frequently asked questions

Who is Luau for GDScript Developers for?

For people who already write GDScript and want to learn Luau. Each lesson starts from GDScript you know and shows how Luau does the same thing, so you skip the beginner basics.

Do I need to know Luau already?

No. The course starts with your first Luau program. You need GDScript basics: variables, conditions, loops, functions and collections.

How many lessons does Luau for GDScript Developers have?

Luau for GDScript Developers contains 48 interactive lessons you can complete at your own pace.

What does Luau for GDScript Developers cover?

The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.

Is Luau for GDScript Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Luau for GDScript Developers for free

Get started