So if you are unaware Roblox cracked down on all of the find server location stuff and only letting you get the country. So to counter this I made this script here which is able to find you servers location. It works by finding the latitude and longitude and then using that info to find out where the server is. Hopefully helps as I spent like 6 hours trying to find a way to find the server location and just had to make this.
local HttpService = game:GetService("HttpService")
local function getServerDetails()
local url = "https://ipconfig.io/json"
local success, response = pcall(function()
return HttpService:GetAsync(url)
end)
if success then
local data = HttpService:JSONDecode(response)
return data.country, data.latitude, data.longitude
else
warn("Failed to get server details: ", response)
return "Unknown", 0, 0
end
end
local function getCityAndRegion(latitude, longitude)
local url = "https://nominatim.openstreetmap.org/reverse?format=json&lat=" .. latitude .. "&lon=" .. longitude
local success, response = pcall(function()
return HttpService:GetAsync(url)
end)
if success then
local data = HttpService:JSONDecode(response)
return data.address.city or "Unknown", data.address.state or "Unknown"
else
warn("Failed to get city and region: ", response)
return "Unknown", "Unknown"
end
end
local function printLocationDetails()
local country, latitude, longitude = getServerDetails()
local city, region = getCityAndRegion(latitude, longitude)
print("Country: " .. country)
print("State: " .. region)
print("City: " .. city)
end
printLocationDetails()