How did this game find where I live?

Okay so I found this game that said where I live.

I got really scared but after I found a PolicyService did that. I wrote some small script but the output is country code and not country name itself. I’ll put code here:

local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

local result, code = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, player)

if result then
	print("You are from "..code)
end
2 Likes

hello sslcertificate.

i think you mentioned my game. I used https://restcountries.com/ so i can change the country code into country name itself. i also used HttpService to use this api. ill post a nice snippet so you can learn/use it.

local LocalizationService = game:GetService("LocalizationService")
local plr = game:GetService("Players").PlayerAdded:Wait()

local HttpService = game:GetService("HttpService")

local result, code = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, plr)

local url = "https://restcountries.com/v3.1/alpha/"..code 

local response = HttpService:GetAsync(url)
local data = HttpService:JSONDecode(response)

if result then
wait(5)
 print(data[1].name.common)
end

make sure to enable HttpEnabled :wink: (you can use this to enable it game:GetService("HttpService").HttpEnabled = true)
(also this is my first devforum post)

3 Likes

wow the owner of the game himself replied me… ill reply if its really working or not

Thank you so much Robloenes2001! I managed to make something like your game. I’ll mark this as solution.

Also welcome to the DevForum!

no problem, you can always ask me if you need help :wink:

I actuall made a library that not only tells where you live it also shows your country flag and emoji: CountryService (Country data Module) - Resources / Community Resources - DevForum | Roblox

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