How to get a Server Location/Region on Roblox

Right, but this has started happening a a little over a week ago. The ping was fine then, but now the ping took a huge hit and most players can’t play for long before the game kicks them out and disconnects. Also there is a big issue where the entire server simply shuts down and shows error code 17.

Just look at how much a big drop has happened on my engagement:

Since most of my players are in Russia, the game is always laggy because every server is constantly very far way from them, even the dedicated ones for Russian players. And it’s defo not my game being more demanding, because the game previously had 3K concurrent players (right now its 1.5K-2K) and the ping was like it should be.

Whatever this is, it’s really hurting my players and revenue and it shouldn’t be like this. Every single server, even Private Servers are in the US :sob:

edit: you can check the server location at the information board

3 Likes

Hello @Build2Inspire ,

Thank you for reaching out with this query, I researched this to find the reason behind a sudden hit on your game locations. And apparently, there are solutions for this, but here’s the reason behind it:

This is a server locations data post by @TheShowCaseMaker as of 2022.
Data collected from various sources show evidence that not many servers have been added till now from 2022.

So let’s assume that data to be valid for now.

If you take a closer look at the geographical location of Russia.

Russia is at the top, and nearly every other server is almost the same distance from Russia.

Few in Europe and one in India and Japan.

And considering the fact Russia is a very vast country, at any point in time in Russia, it is morning/afternoon and evening in the nearby countries. (Note that, the network traffic is usually high in these time phases) but low in midnight-phased countries atm like European Union Countries. And Russians can get the benefit of the European Union being slower in the timezone. And by this, Russians can enjoy the game in the morning and nearly till evening without having this issue much evident earlier.

And data found in various sources, found on Google says:

There is an enormous amount of new player joinees from India and Southern Asia.

This rise of players visibly seen after August 2023, has made the servers previously free in the European Union a lot more occupied, and leaving a lot of servers of the people in these countries to get a location far from them, which is the United States servers at this moment.

If nothing is done, the issue will be resolved once Roblox manages to build/obtain new servers to manage the increased network traffic and concurrent CCU on the platform.
But we never know when Roblox will do that, so you have to find a solution for it. As far now, I never heard or known about changing a server location of servers on Roblox, as they are automated. Please let us know if you find any solution :slight_smile:

1 Like

So, I found a slight solution. It’s definitely not perfect, but more players are getting less lag, and the ping has improved by a lot.

Could this script be better? Probably. But I’m lazy, so I simply got an AI to fill in the countries according to their continent/region and fill in the place id on a table.

If anyone is also having this issue and wants to use this, you can probably give ChatGPT this script and fill in the Place IDs for you instead of having to do it manually.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local LocalizationService = game:GetService("LocalizationService")

local countryCodes = {
	US = 15573797306, -- North/South America
	GB = 15573796351, -- United Kingdom
	CA = 15573797306, -- Canada
	AF = 15597287950, -- Afghanistan
	AX = 15597287950, -- Aland Islands
	AL = 15597287950, -- Albania
	DZ = 15597287950, -- Algeria
	AS = 15597287950, -- American Samoa
	AD = 15597287950, -- Andorra
	AO = 15597287950, -- Angola
	AI = 15597287950, -- Anguilla
	AQ = 15597287950, -- Antarctica
	AG = 15597287950, -- Antigua and Barbuda
	AR = 15597287950, -- Argentina
	AM = 15597287950, -- Armenia
	AW = 15597287950, -- Aruba
	AU = 15597289462, -- Australia/Oceania
	AT = 15573796351, -- Austria
	AZ = 15597287950, -- Azerbaijan
	BS = 15573797306, -- Bahamas
	BH = 15597287950, -- Bahrain
	BD = 15597287950, -- Bangladesh
	BB = 15597287950, -- Barbados
	BY = 15573799206, -- Belarus
	BE = 15597287950, -- Belgium
	BZ = 15597287950, -- Belize
	BJ = 15597287950, -- Benin
	BM = 15597287950, -- Bermuda
	BT = 15597287950, -- Bhutan
	BO = 15597287950, -- Bolivia
	BQ = 15597287950, -- Bonaire, Saint Eustatius and Saba
	BA = 15597287950, -- Bosnia and Herzegovina
	BW = 15597287950, -- Botswana
	BV = 15597287950, -- Bouvet Island
	BR = 15597287950, -- Brazil
	IO = 15597287950, -- British Indian Ocean Territory
	BN = 15597287950, -- Brunei Darussalam
	BG = 15597287950, -- Bulgaria
	BF = 15597287950, -- Burkina Faso
	BI = 15597287950, -- Burundi
	KH = 15597287950, -- Cambodia
	CM = 15597287950, -- Cameroon
	CV = 15597287950, -- Cape Verde
	KY = 15597287950, -- Cayman Islands
	CF = 15597287950, -- Central African Republic
	TD = 15597287950, -- Chad
	CL = 15597287950, -- Chile
	CN = 15597287950, -- China
	CX = 15597287950, -- Christmas Island
	CC = 15597287950, -- Cocos Islands
	CO = 15597287950, -- Colombia
	KM = 15597287950, -- Comoros
	CG = 15597287950, -- Congo
	CD = 15597287950, -- Congo (DRC)
	CK = 15597287950, -- Cook Islands
	CR = 15597287950, -- Costa Rica
	CI = 15597287950, -- Ivory Coast
	HR = 15597287950, -- Croatia
	CW = 15597287950, -- Curaçao
	CY = 15597287950, -- Cyprus
	CZ = 15597287950, -- Czech Republic
	DK = 15597287950, -- Denmark
	DJ = 15597287950, -- Djibouti
	DM = 15597287950, -- Dominica
	DO = 15597287950, -- Dominican Republic
	EC = 15597287950, -- Ecuador
	EG = 15597287950, -- Egypt
	SV = 15597287950, -- El Salvador
	GQ = 15597287950, -- Equatorial Guinea
	ER = 15597287950, -- Eritrea
	EE = 15597287950, -- Estonia
	ET = 15597287950, -- Ethiopia
	FK = 15597287950, -- Falkland Islands (Malvinas)
	FO = 15597287950, -- Faroe Islands
	FJ = 15597287950, -- Fiji
	FI = 15597287950, -- Finland
	FR = 15597287950, -- France
	GF = 15597287950, -- French Guiana
	PF = 15597287950, -- French Polynesia
	TF = 15597287950, -- French Southern Territories
	GA = 15597287950, -- Gabon
	GM = 15597287950, -- Gambia
	GE = 15597287950, -- Georgia
	DE = 15597287950, -- Germany
	GH = 15597287950, -- Ghana
	GI = 15597287950, -- Gibraltar
	GR = 15597287950, -- Greece
	GL = 15597287950, -- Greenland
	GD = 15597287950, -- Grenada
	GP = 15597287950, -- Guadeloupe
	GU = 15597287950, -- Guam
	GT = 15597287950, -- Guatemala
	GG = 15597287950, -- Guernsey
	GN = 15597287950, -- Guinea
	GW = 15597287950, -- Guinea-Bissau
	GY = 15597287950, -- Guyana
	HT = 15597287950, -- Haiti
	HM = 15597287950, -- Heard Island and the McDonald Islands
	VA = 15597287950, -- Holy See
	HN = 15597287950, -- Honduras
	HK = 15597287950, -- Hong Kong
	HU = 15597287950, -- Hungary
	IS = 15597287950, -- Iceland
	IN = 15597287950, -- India
	ID = 15597287950, -- Indonesia
	IQ = 15597287950, -- Iraq
	IE = 15597287950, -- Ireland
	IM = 15597287950, -- Isle of Man
	IL = 15597287950, -- Israel
	IT = 15597287950, -- Italy
	JM = 15597287950, -- Jamaica
	JP = 15597287950, -- Japan
	JE = 15597287950, -- Jersey
	JO = 15597287950, -- Jordan
	KZ = 15573799206, -- Kazakhstan
	KE = 15597287950, -- Kenya
	KI = 15597287950, -- Kiribati
	KR = 15597287950, -- Korea
	KW = 15597287950, -- Kuwait
	KG = 15573799206, -- Kyrgyzstan
	LA = 15597287950, -- Laos
	LV = 15597287950, -- Latvia
	LB = 15597287950, -- Lebanon
	LS = 15597287950, -- Lesotho
	LR = 15597287950, -- Liberia
	LY = 15597287950, -- Libya
	LI = 15597287950, -- Liechtenstein
	LT = 15597287950, -- Lithuania
	LU = 15597287950, -- Luxembourg
	MO = 15597287950, -- Macao
	MK = 15597287950, -- Macedonia
	MG = 15597287950, -- Madagascar
	MW = 15597287950, -- Malawi
	MY = 15597287950, -- Malaysia
	MV = 15597287950, -- Maldives
	ML = 15597287950, -- Mali
	MT = 15597287950, -- Malta
	MH = 15597287950, -- Marshall Islands
	MQ = 15597287950, -- Martinique
	MR = 15597287950, -- Mauritania
	MU = 15597287950, -- Mauritius
	YT = 15597287950, -- Mayotte
	MX = 15597287950, -- Mexico
	FM = 15597287950, -- Micronesia
	MD = 15597287950, -- Moldova
	MC = 15597287950, -- Monaco
	MN = 15597287950, -- Mongolia
	ME = 15597287950, -- Montenegro
	MS = 15597287950, -- Montserrat
	MA = 15597287950, -- Morocco
	MZ = 15597287950, -- Mozambique
	MM = 15597287950, -- Myanmar
	NA = 15597287950, -- Namibia
	NR = 15597287950, -- Nauru
	NP = 15597287950, -- Nepal
	NL = 15597287950, -- Netherlands
	AN = 15597287950, -- Netherlands Antilles
	NC = 15597287950, -- New Caledonia
	NZ = 15597287950, -- New Zealand
	NI = 15597287950, -- Nicaragua
	NE = 15597287950, -- can't say that
	NG = 15597287950, -- also can't say this
	NU = 15597287950, -- Niue
	NF = 15597287950, -- Norfolk Island
	MP = 15597287950, -- Northern Mariana Islands
	NO = 15597287950, -- Norway
	OM = 15597287950, -- Oman
	PK = 15597287950, -- Pakistan
	PW = 15597287950, -- Palau
	PS = 15597287950, -- Palestine
	PA = 15597287950, -- Panama
	PG = 15597287950, -- Papua New Guinea
	PY = 15597287950, -- Paraguay
	PE = 15597287950, -- Peru
	PH = 15597287950, -- Philippines
	PN = 15597287950, -- Pitcairn Islands
	PL = 15597287950, -- Poland
	PT = 15597287950, -- Portugal
	PR = 15597287950, -- Puerto Rico
	QA = 15597287950, -- Qatar
	RE = 15597287950, -- Reunion
	RO = 15597287950, -- Romania
	RU = 15573799206, -- Russian Federation
	RW = 15597287950, -- Rwanda
	BL = 15597287950, -- Saint Barthelemy
	SH = 15597287950, -- Saint Helena, Ascension and Tristan da Cunha
	KN = 15597287950, -- Saint Kitts and Nevis
	LC = 15597287950, -- Saint Lucia
	MF = 15597287950, -- Saint Martin
	PM = 15597287950, -- Saint Pierre and Miquelon
	VC = 15597287950, -- Saint Vincent and the Grenadines
	WS = 15597287950, -- Samoa
	SM = 15597287950, -- San Marino
	ST = 15597287950, -- Sao Tome and Principe
	SA = 15597287950, -- Saudi Arabia
	SN = 15597287950, -- Senegal
	RS = 15597287950, -- Serbia
	SC = 15597287950, -- Seychelles
	SL = 15597287950, -- Sierra Leone
	SG = 15597287950, -- Singapore
	SX = 15597287950, -- Sint Maarten
	SK = 15597287950, -- Slovakia
	SI = 15597287950, -- Slovenia
	SB = 15597287950, -- Solomon Islands
	SO = 15597287950, -- Somalia
	ZA = 15597287950, -- South Africa
	GS = 15597287950, -- South Georgia and the South Sandwich Islands
	SS = 15597287950, -- South Sudan
	ES = 15597287950, -- Spain
	LK = 15597287950, -- Sri Lanka
	SR = 15597287950, -- Suriname
	SJ = 15597287950, -- Svalbard and Jan Mayen
	SZ = 15597287950, -- Swaziland
	SE = 15597287950, -- Sweden
	CH = 15597287950, -- Switzerland
	TW = 15597287950, -- Taiwan
	TJ = 15597287950, -- Tajikistan
	TZ = 15597287950, -- Tanzania
	TH = 15597287950, -- Thailand
	TL = 15597287950, -- Timor-Leste
	TG = 15597287950, -- Togo
	TK = 15597287950, -- Tokelau
	TO = 15597287950, -- Tonga
	TT = 15597287950, -- Trinidad and Tobago
	TN = 15597287950, -- Tunisia
	TR = 15597287950, -- Turkey
	TM = 15597287950, -- Turkmenistan
	TC = 15597287950, -- Turks and Caicos Islands
	TV = 15597287950, -- Tuvalu
	UG = 15597287950, -- Uganda
	UA = 15597287950, -- Ukraine
	AE = 15597287950, -- United Arab Emirates
	UM = 15597287950, -- United States Minor Outlying Islands
	UY = 15597287950, -- Uruguay
	UZ = 15597287950, -- Uzbekistan
	VU = 15597287950, -- Vanuatu
	VE = 15597287950, -- Venezuela
	VN = 15597287950, -- Vietnam
	VG = 15597287950, -- Virgin Islands (British)
	VI = 15597287950, -- Virgin Islands (US)
	WF = 15597287950, -- Wallis and Futuna
	EH = 15597287950, -- Western Sahara
	YE = 15597287950, -- Yemen
	ZM = 15597287950, -- Zambia
	ZW = 15597287950, -- Zimbabwe
	CU = 15597287950, -- Cuba
	IR = 15597287950, -- Iran
	SY = 15597287950, -- Syria
	KP = 15597287950 -- North Korea
}

local function FindRegion()
	local player = Players.LocalPlayer

	local success, countryCode = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, player)

	if success then
		print("Country Code:", countryCode)

		local placeId = countryCodes[countryCode]

		if placeId then
			script.Parent.Parent.Status.Text = "Connecting to server for country: " .. countryCode .. "..."

			TeleportService:Teleport(placeId)

		
		else
			script.Parent.Parent.Status.Text = "Connecting to Global server..."
			wait(1)
			TeleportService:Teleport(15597512029)
		end
	else
		script.Parent.Parent.Status.Text = "Connecting to Global server..."
		wait(1)
		TeleportService:Teleport(15597512029)
	end
end

script.Parent.MouseButton1Click:Connect(FindRegion)
2 Likes

What’s wrong with just using this: http://ip-api.com/json/

Also how fast are the responses? What if you have a big game with many requests to make?

1 Like

If you can afford to pay $13.99 every month for your game, you can go with http://ip-api.com/json/

However, a risk-free solution is what I updated the tutorial to, you can do it for free using the tools I mentioned in this tutorial. However, it’s not an issue with requests. You would make the requests only once when the server is created, which isn’t resource intensive after all, and even if your server size is 1, and many players will join, it wouldn’t be an issue.
image

Also note that, when your server size is 1, and many players play your game, it would be hard to achieve the server location with a Free API Plan as it:
image

It has a 500 Limit per day, if you’re looking to spend money around 9$ - 15$, you can go with IP API, additionally, ip-api has infinite requests and does not have any issues.

And a slightly cheaper option would be the following:
image
In rapid API.

Currently ip-api is free to use. I don’t know if I should get the priced version instead. We have a sizeable game and making a request on server creation sometimes does fail. Should I buy the 13.99 version instead?

Also with the rapid API one, it doesn’t return the correct location if I have a VPN on, whereas ip-api does.

It works completely right with VPN, a VPN will also affect the Roblox server location so you are getting a different server, however, I don’t own the API.

The ip-API is no longer free to use, unfortunately.

Very useful guide, thank you for updating it.
Although I do have a problem; rapidapi doesn’t give me any information about the city, it just returns nil for that specific value. It isn’t a huge issue (I’m just using the timezone instead) but I am curious if anyone else has a similar problem and if they managed to fix it.

1 Like

I thought North Korea doesn’t play roblox :skull: lol

2 Likes

Is this still relevant? I’ve been trying to activate it, but it keeps returning 403 (Forbidden) and I’ve tried to reiterate it through a loop however it’s still returning the same thing.

1 Like

It occurs when your API key is entered wrong or when you are not firing the API correctly, please recheck your script.

1 Like

I’ve just tried to reuse your sample script and it does not print out the country. The API key is correct from what I know and so is the rapid api key.

EDIT: Sorry for the confusion-- I wasn’t subscribed

1 Like

being a builder and trying to understand what is going on and trying to get this in my game is very hard.
first i have no idea where do i even put this script. i made my acc in the https://rapidapi.com website and it works there now how do i get the info to my game and also display it?
saw a person say to make a gui and then text label and in it a local script but what now? since my experience is basically 0 and can only read a script how do i go from here?

Head over the URL mentioned in the OP and then click on “Subscribe to test”, and then you get your details in the right-side code example, it might be node.js or any language, but it’s easy to read as the labels and their value is needed, which can be easily read from the code. or you can scroll down and read the parameters and you will get the values.

And after you get the values, you can simply check the code example, it would be hard to explain how to code here, because you need to know the basics in order for you to understand the code. But what it does is, it calls the API and then it will show the data in it simply.

1 Like

I don’t even know how to make a text label show the stuff😭 and to get the info from a website to a code it just insane for me

1 Like

you could have used RequestAsync because it doesnt error and you dont have to wrap it around pcall

1 Like


doesnt seem to work anymore man, and my code does nothing

Use “https://ipconfig.io/json” for getting location. it returns json code that you can access just like the tutorial, no api key required

(TESTED)(IN STUDIO)

local HttpService = game:GetService("HttpService")

pcall(function()
    local response = HttpService:GetAsync("https://ipconfig.io/json")
    if response then
        local decodedResponse = HttpService:JSONDecode(response)
        print(decodedResponse["country"])
    else
        print("Failed to fetch data")
    end
end)

That api doesnt give as much info as the last api the OP posted but its still enough for a server display. Theres a ton of different formats but sticking with JSON would be wise.

2 Likes

this was actually the first thing i used and it didnt work, it printed out my location in studio, but not ingame

1 Like

Sometimes, the API fails to respond or the IP cannot be detected by the IPT framework of that host service, then the following will return “” or empty. This isn’t your script issue, it’s the host service or IPR or IP issue.