So, I’ve seen some PvP\FPS games having a GUI element displaying - what I assume to be - the server’s location. Example here.
From what I’ve seen on the DevForum, the location is picked based on the first player to join the server. For example, if the first player joining is from Europe, the server will be located somewhere in Europe, or if the first player joining is from the US, the server will be located in the US (duh lol).
I’ve tried searching on the DevForum, Wiki, and Google, but nothing came up. Someone in a thread suggested using JSON code and do something like this:
local longitude = http:JSONDecode(http:GetAsync('http://ip-api.com/json/')).lon
local host = 'NA'
if(longitude>-180 and longitude<=-105)then
host = 'WUS'
elseif(longitude>-105 and longitude<=-90)then
host = 'CUS'
elseif(longitude>-90 and longitude<=0)then
host = 'EUS'
elseif(longitude<=75 and longitude>0)then
host = 'EU'
elseif(longitude<=180 and longitude>75)then
host = 'AS'
end
The most I can do is making the if loop changing the TextLabel's text but I have no idea how to grab the server location.

5 comments
I don't really see a reason to use this just to show it on a player's gui other for it to be "cool"?
I found this on a devforum post ( https://devforum.roblox.com/t/game-gethostlocation/49488/3 ). The post itself is about proposing a new way to find the hosting location, but the comment here shows a method, by which you could achieve it https://prnt.sc/v9lks4
@TheOnlineItalian213: it's for a friend's commission. I could say I have no idea how to do it but I was curious to see how it could be possibly done. Besides, it's useful for PvP\FPS games where lag influences the game experience heavily. If I see the server host is too far away from me, I can just change server hoping to find one closer to me, which would result in less lag.
@Gey4Jesus69: yes, that's the thread I saw and helped quite a bit. I'm not really experienced though so I don't even know how to start with what the person in the screenshot suggested lol.
I personally find it rather scary that when you send a GET request to the JSON api that you've listed, you can get the exact location, down to the zip code. At any rate, that's how you'll have to do it (forget the longitudinal stuff)