How can I get the servers region? like: "The Region is US!"

Just wondering, seen a game like criminality do that and I was wondering.

local http = game:GetService('HttpService')
local whatever = workspace.ServerLocation -- change it to whatever here, so that it can replicate to client

-- this url has flags that only return information that's specifically needed.
local url = "http://ip-api.com/json/?fields=16394"
local region_format = "%s, %s"

local response = http:JSONDecode(http:GetAsync(url))

if response.status == "success" then
    whatever.Value = string.format(
        region_format, 
        response.countryCode, 
        response.regionName
    )
end

Forked from: How to get a server Location on Roblox - #45 by Gojinhan

1 Like

This doesn’t work, and its not for a value its for text

Try this

local url = "http://ip-api.com/json/?fields=16394"
local response = http:JSONDecode(http:GetAsync(url))

print("The Region is ".. response.countryCode.."!")
2 Likes

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