How to get the flag of the country a player lives in

Hello I’m trying to get the flag of the country a player lives in. I know that

game:GetService("LocalizationService"):GetCountryRegionForPlayerAsync(game.Players.LocalPlayer)

exists however there are 195 countries and finding an image for all of them would take forever.
is there a better method of doing this?

also if I were to make a dictonary containing a list of maybe the top 20 countries in population how do I know the acryonom that it will return? is there a list somewhere out there

2 Likes

It looks like there’s a module made for getting the flag of a specific country, with an article, example place, and the code for it on GitHub.

I don’t use github why cant they just make a model? also downloading models is so annoying why couldnt they just provide all the code???

The code on GitHub is just the source code, to actually use it all you need to do is put this module script in the Replicated Storage and require it in your scripts. If you don’t know how to use a module, I could help you.

Here is the example code they provided:

--[[
    This is a local script inside of the player scripts
]]

--Services||
local LocalizationService 	= game:GetService("LocalizationService")
local ReplicatedStorage 	= game:GetService("ReplicatedStorage")
local Players 				= game:GetService("Players")
----------||

--Dependencies||
local countries = require(ReplicatedStorage:WaitForChild("ProoCountry"))
--------------||

--Variables||
local player = game.Players.LocalPlayer
-----------||

--Methods||
local result, code = pcall(function()
	--Get the country code
	return LocalizationService:GetCountryRegionForPlayerAsync(player)
end)

if result and code ~= nil then
	
	--Get the information about this count (both name and flag)
	local countryData = countries.getCountry(code)
	print(countryData)
else
	warn("Couldn't proccess players country")
end
---------||

Maybe check out the link next time so you actually understand how to use this module because it’s pretty easy to put and use in Studio.

damn kind of passive aggressive. And yes I did check the link out for your information as well as going to the github. I copied the giant table of all the countries and am working with it right now.

Oh, ok. I’m sorry if I sounded a bit passive-aggressive, my fault. Glad to see it working for you, though!

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