Hello!
I created a simple and easy function for anyone to turn a country code into an emoji!
You can use this however you would like, for aesthetics,global chat messages, nametags, you get the idea!
Function:
function countryCodeToEmoji(countryCode)
countryCode = countryCode:upper()
local firstLetter = countryCode:sub(1, 1)
local secondLetter = countryCode:sub(2, 2)
local firstEmoji = utf8.char(0x1F1E6 + (firstLetter:byte() - 65))
local secondEmoji = utf8.char(0x1F1E6 + (secondLetter:byte() - 65))
return firstEmoji .. secondEmoji
end
Pretty simple, hope it helps someone!
Usage:
local LocalizationService = game:GetService("LocalizationService")
local Player = game.Players.LocalPlayer
local result, code = pcall(function()
return LocalizationService:GetCountryRegionForPlayerAsync(Player)
end)
The code above will get you the country code of the LocalPlayer. If the player is from the United States it will return “US”
local LocalizationService = game:GetService("LocalizationService")
local Player = game.Players.LocalPlayer
function countryCodeToEmoji(countryCode) -- // using our function
countryCode = countryCode:upper()
local firstLetter = countryCode:sub(1, 1)
local secondLetter = countryCode:sub(2, 2)
local firstEmoji = utf8.char(0x1F1E6 + (firstLetter:byte() - 65))
local secondEmoji = utf8.char(0x1F1E6 + (secondLetter:byte() - 65))
return firstEmoji .. secondEmoji
end
local result, code = pcall(function()
return LocalizationService:GetCountryRegionForPlayerAsync(Player)
end)
local countryEmoji = countryCodeToEmoji(code)
-- // do whatever with the emoji
Heres how I used it:
Example 1
Yes… I copied Pet Sim haha.
Thank you for reading!
(if this helps you feel free to like )