Skip to main content

CountryService

Contains all the methods from this library. It is used to get names, icons and flags for every country that exists

Properties

Country

CountryService.Country: Country

Contains the Country class used to retain country data

Functions

GetCountryByCode

CountryService:GetCountryByCode(countryCodestring) → Country

Returns the country object by the country code. By default this returns the United States in case it cannot find any country with the given code

local CountryService = require(ReplicatedStorage.CountryService)

local country: CountryService.Country = CountryService:GetCountryByCode("US")
print(country.name) -- United States
print(country.emoji) -- 🇺🇸
print(country.decal) -- rbxassetid://123456789

GetAllCountries

CountryService:GetAllCountries() → {[string]Country}

Returns all the countries that exist in a dictionary format


local CountryService = require(ReplicatedStorage.CountryService)

local countries: {[string]: CountryService.Country} = CountryService:GetAllCountries()

for code, country: CountryService.Country in countries do
    print(code, country.name) -- Will print every existing name and code
end

GetMyCountry

This item only works when running on the client. ClientThis is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
CountryService:GetMyCountry() → Country?

Returns your own Country. Only works when called from a client script

local CountryService = require(ReplicatedStorage.CountryService)

local country: CountryService.Country = CountryService:GetMyCountry()
print(country.name) -- United States

GetMyCountryCode

This item only works when running on the client. ClientThis is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
CountryService:GetMyCountryCode() → string--

Country Code

Gets the country code of the player. Only works when called from a client script

local CountryService = require(ReplicatedStorage.CountryService)

local countryCode: string = CountryService:GetMyCountryCode()
print(countryCode) -- US

GetPlayerCountryCode

CountryService:GetPlayerCountryCode(playerPlayer) → string--

Country Code

Gets the country code by the player object

local CountryService = require(ReplicatedStorage.CountryService)

local countryCode: string = CountryService:GetPlayerCountryCode(player)
print(countryCode) -- US

GetPlayerCountry

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
CountryService:GetPlayerCountry(playerPlayer) → Country

Gets a country object by the player object

local CountryService = require(ReplicatedStorage.CountryService)

local country: CountryService.Country = CountryService:GetPlayerCountry(player)
print(country.name) -- United States
Show raw api
{
    "functions": [
        {
            "name": "_Init",
            "desc": "Initializes the events for CountryService and loads the country codes",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 44,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_InitServer",
            "desc": "Inits necessary code on the server-side",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "realm": [
                "Server"
            ],
            "private": true,
            "source": {
                "line": 68,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_InitClient",
            "desc": "Inits necessary code on the client-side",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "private": true,
            "source": {
                "line": 90,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "GetCountryByCode",
            "desc": "Returns the country object by the country code. By default this returns the United States\nin case it cannot find any country with the given code\n\n```lua\nlocal CountryService = require(ReplicatedStorage.CountryService)\n\nlocal country: CountryService.Country = CountryService:GetCountryByCode(\"US\")\nprint(country.name) -- United States\nprint(country.emoji) -- 🇺🇸\nprint(country.decal) -- rbxassetid://123456789\n```",
            "params": [
                {
                    "name": "countryCode",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Country"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 121,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "GetAllCountries",
            "desc": "Returns all the countries that exist in a dictionary format\n\n```lua\n\nlocal CountryService = require(ReplicatedStorage.CountryService)\n\nlocal countries: {[string]: CountryService.Country} = CountryService:GetAllCountries()\n\nfor code, country: CountryService.Country in countries do\n    print(code, country.name) -- Will print every existing name and code\nend\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{[string]: Country}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 141,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "GetMyCountry",
            "desc": "Returns your own Country. Only works when called from a client script\n\n```lua\nlocal CountryService = require(ReplicatedStorage.CountryService)\n\nlocal country: CountryService.Country = CountryService:GetMyCountry()\nprint(country.name) -- United States\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Country?"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "yields": true,
            "source": {
                "line": 160,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "GetMyCountryCode",
            "desc": "Gets the country code of the player. Only works when called from a client script\n\n```lua\nlocal CountryService = require(ReplicatedStorage.CountryService)\n\nlocal countryCode: string = CountryService:GetMyCountryCode()\nprint(countryCode) -- US\n```",
            "params": [],
            "returns": [
                {
                    "desc": "Country Code",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "yields": true,
            "source": {
                "line": 183,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "GetPlayerCountryCode",
            "desc": "Gets the country code by the player object\n\n```lua\nlocal CountryService = require(ReplicatedStorage.CountryService)\n\nlocal countryCode: string = CountryService:GetPlayerCountryCode(player)\nprint(countryCode) -- US\n```",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "Country Code",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 201,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "GetPlayerCountry",
            "desc": "Gets a country object by the player object\n\n```lua\nlocal CountryService = require(ReplicatedStorage.CountryService)\n\nlocal country: CountryService.Country = CountryService:GetPlayerCountry(player)\nprint(country.name) -- United States\n```",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Country"
                }
            ],
            "function_type": "method",
            "yields": true,
            "source": {
                "line": 220,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_ServerPlayerAdded",
            "desc": "Used to grab the player country",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "realm": [
                "Server"
            ],
            "private": true,
            "source": {
                "line": 233,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_ClientPlayerAdded",
            "desc": "Used to grab the player country",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "realm": [
                "Server"
            ],
            "private": true,
            "source": {
                "line": 247,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_PlayerRemoved",
            "desc": "Used to clear up the cache",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 269,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_GetCountryCode",
            "desc": "Gets the code from a players country",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 282,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_WaitForPlayerCode",
            "desc": "Waits for the player code to be retrieved",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 317,
                "path": "src/CountryService/init.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "Country",
            "desc": "Contains the Country class used to retain country data",
            "lua_type": "Country",
            "source": {
                "line": 26,
                "path": "src/CountryService/init.lua"
            }
        },
        {
            "name": "_cachedCodes",
            "desc": "Contains the Country class used to retain country data",
            "lua_type": "{[Player]: string}",
            "private": true,
            "source": {
                "line": 35,
                "path": "src/CountryService/init.lua"
            }
        }
    ],
    "types": [],
    "name": "CountryService",
    "desc": "Contains all the methods from this library. It is used to get names, icons and flags for\nevery country that exists",
    "source": {
        "line": 19,
        "path": "src/CountryService/init.lua"
    }
}