Skip to content

Instantly share code, notes, and snippets.

@cxmeel
Created December 3, 2022 20:01
Show Gist options
  • Save cxmeel/40c9e3829c71ad656696a45b9f54647b to your computer and use it in GitHub Desktop.
Save cxmeel/40c9e3829c71ad656696a45b9f54647b to your computer and use it in GitHub Desktop.
Generate a flag emoji from the player's region
--!strict
local regionalIndicators = { A = "๐Ÿ‡ฆ", B = "๐Ÿ‡ง", C = "๐Ÿ‡จ", D = "๐Ÿ‡ฉ", E = "๐Ÿ‡ช", F = "๐Ÿ‡ซ", G = "๐Ÿ‡ฌ", H = "๐Ÿ‡ญ", I = "๐Ÿ‡ฎ", J = "๐Ÿ‡ฏ", K = "๐Ÿ‡ฐ", L = "๐Ÿ‡ฑ", M = "๐Ÿ‡ฒ", N = "๐Ÿ‡ณ", O = "๐Ÿ‡ด", P = "๐Ÿ‡ต", Q = "๐Ÿ‡ถ", R = "๐Ÿ‡ท", S = "๐Ÿ‡ธ", T = "๐Ÿ‡น", U = "๐Ÿ‡บ", V = "๐Ÿ‡ป", W = "๐Ÿ‡ผ", X = "๐Ÿ‡ฝ", Y = "๐Ÿ‡พ", Z = "๐Ÿ‡ฟ" }
local function constructFlagEmoji(region: string): string
local flag = {}
for _, char in region:split("") do
table.insert(flag, regionalIndicators[char:upper()])
end
return table.concat(flag, "")
end
local region = LocalizationService:GetCountryRegionForPlayerAsync(player)
local flag = constructFlagEmoji(region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment