Skip to main content

ServerRegion

This item only works when running on the server. Server

Extra information about a game server's region, referenced by game.ServerRegion, such as geographic coordinates and country.

Since this is a server-only module, ensure to list the package under [server-dependencies] within your wally.toml file.

Memory Usage

Due to how Luau works, this module uses upwards of 7MB of heap memory. Therefore, it is recommended to use the getAndDestroy() function, which will destroy the ModuleScript after fetching the region information. This will free up the heap memory used. Call this function once and cache the result.

-- Custom ServerRegion ModuleScript which proxies the one-time call to getAndDestroy
return require(ServerStorage.ServerPackages.ServerRegion).getAndDestroy()

Types​

Region​

interface Region {
Lat: number--

Latitude

Lon: number--

Longitude

Continent: string
Country: string
IATA: string--

Three-letter location identifier

}

Functions​

get​

ServerRegion.get() → Region

Gets the server region.

getAndDestroy​

ServerRegion.getAndDestroy() → Region

Gets the server region, and then destroys the source ModuleScript to free up heap memory.

Show raw api
{
    "functions": [
        {
            "name": "get",
            "desc": "Gets the server region.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Region\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 9111,
                "path": "modules/server-region/init.luau"
            }
        },
        {
            "name": "getAndDestroy",
            "desc": "Gets the server region, and then destroys the source ModuleScript to free up heap memory.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Region\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 9122,
                "path": "modules/server-region/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Region",
            "desc": "",
            "fields": [
                {
                    "name": "Lat",
                    "lua_type": "number",
                    "desc": "Latitude"
                },
                {
                    "name": "Lon",
                    "lua_type": "number",
                    "desc": "Longitude"
                },
                {
                    "name": "Continent",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "Country",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "IATA",
                    "lua_type": "string",
                    "desc": "Three-letter location identifier"
                }
            ],
            "source": {
                "line": 36,
                "path": "modules/server-region/init.luau"
            }
        }
    ],
    "name": "ServerRegion",
    "desc": "Extra information about a game server's region, referenced by `game.ServerRegion`, such as geographic coordinates\nand country.\n\nSince this is a server-only module, ensure to list the package under `[server-dependencies]` within your\n`wally.toml` file.\n\n:::warning Memory Usage\nDue to how Luau works, this module uses upwards of 7MB of heap memory. Therefore, it is recommended to use the\n`getAndDestroy()` function, which will destroy the ModuleScript after fetching the region information. This will\nfree up the heap memory used. Call this function once and cache the result.\n```lua\n-- Custom ServerRegion ModuleScript which proxies the one-time call to getAndDestroy\nreturn require(ServerStorage.ServerPackages.ServerRegion).getAndDestroy()\n```\n:::",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 26,
        "path": "modules/server-region/init.luau"
    }
}