To avoid lag in your Roblox game by only showing servers from the player’s region, you could do the following:
Determine server region: When creating a server, the region is usually determined based on availability and load, so it can change.
Filter by region:
To ensure players only see servers from their region, you could implement a script that determines players’ region and only shows servers nearby.
Use Roblox API: The Roblox API can help you determine a player’s region based on their IP address and filter the appropriate servers accordingly.
A script:
local httpService = game:GetService(“HttpService”)
local player = game.Players.LocalPlayer
local ipInfo = httpService:GetAsync(“http://ip-api.com/json/”)
local ipData = httpService:JSONDecode(ipInfo)
local playerRegion = ipData.region
local servers = {} – Your list of servers
local filteredServers = {}
for _, server in ipairs(servers) do
if server.region == playerRegion then
table.insert(filteredServers, server)
end
end
for _, server in ipairs(filteredServers) do
print("Server: " … server.name … " Region: " … server.region)
end
You would have to adapt it and insert it into your game😁.
I hope the script works (I’m not the best scripter) if you have any questions or something doesn’t work just write to me .