What does export do?

Hello, i have a question about export, When you type “export” on a script, for some reason it will change the color of the text, meaning its a function or something else

image

13 Likes

I answered something similar to this in another post, but the Luau GitHub should help you understand (Very bottom)

But from what I can understand, it is used for exporting custom Types for type checking

4 Likes

export is a keyword that only works for module scripts. It’s used for Luau’s type checker.

It gives scripts the ability to access types defined within it, outside of it.

-- module script
local module = {}

export type dictionary = {[any]: any}

return module
-- from another script
local module = require(ModuleScript)

-- you access the type by doing "ModuleScript.Type"
local _table: module.dictionary = {
    index = "value",
}

Edit 5/8/23
For anyone curious, Roblox does have a documentation site for the Type Checker:

56 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.