How to get a players country

I am not english, so I am not very good at it, but I will try my best. :slight_smile:

I am trying to make a game that changes things if someone is from a different country.
For example: There is a TextLabel with “…” in it, but it puts your country in it, or the shorter name for the country. For example US. Note that the TextLabel is just an example.

With country I mean the country they set on roblox in their settings.

1 Like

Timezone would be ok but getting someones country is a little bit more questionable, check the t&cs of roblox as I know you shouldnt get someones location but not the extent of what it applies to.

1 Like

I think the best method would be LocalizationService | Roblox Creator Documentation

1 Like

I already got help from someone else. I am using this to change the theme of my game depending on the country.

1 Like

I checked and through the use of localization service you can see what language the player selected to be used from the website

print(game:GetService(“LocalizationService”).RobloxLocaleId)

fr-fr

edit: to be more specific, that was an example that used something else other than the default english language, and from further checking, if the player does not restart the game client after selecting another change, the language seen as chosen will not refresh

basically, you can use game:GetService(“LocalizationService”).RobloxLocaleId too

An example

if game:GetService(“LocalizationService”).RobloxLocaleId == "fr-fr" then
    print("Lenguage is french")
end
2 Likes

I’m late but I have a proper way for this.

You can use GetCountryRegionForPlayerAsync it’s a function in LocalizationService. This function allows you to extract a player’s region.

Example:

print(game.LocalizationService:GetCountryRegionForPlayerAsync(game.Players.y3r4k)) --> "RU"

Use region to get country:

local Countries = {
      US = "United States",
      UK = "United Kingdom",
      RU = "Russian Federation",
}
local Success, Region = pcall(game.LocalizationService.GetCountryRegionForPlayerAsync, game.LocalizationService, game.Players.y3r4k)
if Success and Region and Countries[Region] then
       print(Countries[Region]) --> "Russian Federation"
end

LocalizationService | Documentation - Roblox Creator Hub

1 Like