Im trying to get the region the server is located in but httpservice wont work, ive tried many different json website thingies but none of them work when in the actual game only in studio. Is there a solution that doesnt requier http service?
Please always check before your post if a similar one exists. You can find the solution here:
âIm trying to get the region the server is located in but httpservice wont workâ Please always check before sending me to another post
local function getServerData()
local suc, getIp = pcall(function()
return HttpService:GetAsync("https://ifconfig.io/all.json")
end)
local ipData = {}
local serverIP
if getIp then
ipData = HttpService:JSONDecode(getIp)
serverIP = ipData["ip"]
end
local success, serverData = pcall(function()
return HttpService:GetAsync("https://ipapi.co/"..serverIP.."/json/")
-- if you plug in the above URL with the IP, you can get the actual
-- raw JSON that includes a list of keys that you can use.
end)
if serverData then
serverData = HttpService:JSONDecode(serverData) -- this returns things like
-- {
-- region = "Virginia"
-- country_code = "US"
-- }
end
-- do something with this data, i.e.
--print(serverdata[region] .. " " .. serverData[country_code]) may print "Toronto, CA"
end
Edit: additional clarification on serverData
https://ipapi.co/YOUR-IP/json/ returns a JSON file that can be decoded and turned into a dictionary. If you plug your IP or the server IP into the actual URL on the browser, you can get something like this:
As the code above, once you decode it, you can just get the info as if it were a simple dictionary
Edit2: You will need HTTP service and API service to get anything about the server information. Otherwise, LocalizationService would be your second best option, although it only tells you what country the player is located in. You can, as @doomguy2164 said, get the first playerâs locale; though the true first player wonât always be consistent.
If OP wanted an AI slop response, they wouldnât have asked here.
Plus, it doesnât even exist.
![]()
ChatGPT can make mistakes. Check important info.
the prompt was âgenerate me a fake response about robloxâs region serviceâ ![]()
Okay I fell for it. Well played.
Whilst looking for ââRegionServiceââ, I stumbled upon LocalizationService, which has the GetCountryRegionForPlayerAsync function. So if you donât want to setup a custom proxy for this, you could take the country of the first player (theyâre the one who influence the server region) who joins the server and based off of that conclude the continent of the server. The average user is either way typically only interested in whether theyâre on a server that is or isnât 20 000 km away from them.
youâre correct, but I do have to point out that the true first player who start up the server may not always be consistent, and regions are not always guaranteed (ROBLOX may still place you in another region if it wishes to do so for good reasons, i.e. you get routed to a server based in Germany if youâre from France and all French servers are down)
this is a real service btw i can prove this
i better not see âRegionService - a new way to get server regionâ in Community Resources in a couple days
you got my hopes up for nothing ![]()
YESSSSS SIR I LOVE YOU IT WORKS
i put the other post as solution to troll others in the future
ROBLOX may still place you in another region if it wishes to do so for good reasons
Which is why I said in my previous reply that that method should only be used to get the continent of the server, since only a few countries host Roblox servers. Most if not all of i.e. Europeans get put in either the UK, the Netherlands, France and Germany.
usually they get put in eastern ukraine or moldova but alr
thanks, please consider marking my reply as a solution ![]()
tried using this, but 99% of the time it returns âHTTP 429â from "return HttpService:GetAsync("https://ipapi.co/â..serverIP..â/json/â)â. pretty sure HTTP 429 is a rate limit error. any ideas on how you could get around this?
You can do this;
local Players = game:GetService("Players")
local LocalizationService = game:GetService("LocalizationService")
Players.PlayerAdded:Connect(function(player)
local region = LocalizationService:GetCountryRegionForPlayerAsync(player)
print(player.Name, region)
end)
Anything deeper may be used for tracking, which violates Robloxâs Terms of Use and Developer Policy. (donât mean that to sound rude, I just canât post or inform as deep as I can go by that rule)
I havenât had issues at all, but there are a few reasons you get a 429
Like any async HTTP calls, you do need to rate-limit the script that calls it. I assume you have wrapped it in a pcall with a debounce or some sort of promise.
Keep in mind that you shouldnât need to call this more than once per start-up.
