How do I make a TextLabel show the server's location?

So, I’ve seen some PvP\FPS games having a GUI element displaying - what I assume to be - the server’s location.
Example:
image
From what I’ve seen on the Forum, 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 Forum, Wiki, and Google, but nothing came up. The closest thing I could find was this suggestion about a :GetHostLocation function, but it obviously didn’t help much.
My question is: how could I make something similar?

2 Likes

A solution, as suggested here, is to base the server’s location off of latitude/longitude as described here:

This uses an external API endpoint to request the IP information - but do keep in mind this typically depends not on location information obtained from the IP address, but based on the registration of the IP address’s location.

Other than that - this information could easily just be assumed, since Roblox when they started out did host all of their servers in eastern Canada (to the best of my knowledge, I could be wrong) - but have since moved a lot of their services over to cloud-based services in recent years on their own IP range - away from physical hosts.

As far as I know the only regions which Amazon Web Services allows custom IP space to be assigned to virtual machines is in specific regions - which can help narrow down where they might have their game servers physically located. However, do keep in mind Amazon does not make the actual physical locations of their data centers public.

Again, this is to the best of my knowledge - I could most certainly be wrong, however nothing as far as I am aware is known about this. This is just stuff I have found through my own journeys and discoveries.

8 Likes

Oh, I completely missed that answer, thank you for pointing it out :slight_smile:
The script is pretty simple but I can’t figure out a way to make it “grab” the server location via the JSON code. Could a PlayerAdded function work? lol I don’t recall a function that allows to detect who is the first player to join the server.

Roblox doesn’t allow you to get the location of the player from anywhere. That would be a vector for violating people’s privacy.

My suggestion is unfortunately the way to go.

Oh, I’m trying to get the server’s location, not the players.
I found a way to do it btw. :))

For those in need, here is the code:

local longitude = http:JSONDecode(http:GetAsync('http://ip-api.com/json/')).lon
local GUI = game:GetService("StarterGui")
local region = GUI.ScreenGui.Frame.ServerRegion

region.Text = "N\A"

if(longitude>-180 and longitude<=-105)then
region.Text = "West US"

elseif(longitude>-105 and longitude<=-90)then
region.Text = "Central US"

elseif(longitude>-90 and longitude<=0)then
region.Text = "East US"

elseif(longitude<=75 and longitude>0)then
region.Text = "Europe"

elseif(longitude<=180 and longitude>75)then
region.Text = "Australia"

end
11 Likes

Where would we put this in?
(filling this space up with letters)

Few people are still referring to this, so I would like to mention a tutorial so people can also get an alternate and different solution.