Not always, seems to be a 50/50 chance, I’ll get an HTTP Error despite only running this code once:
local HttpService = game:GetService("HttpService")
local serverInfo = HttpService:JSONDecode(HttpService:GetAsync("http://ip-api.com/json/"))
local region = serverInfo.regionName
local country = serverInfo.country
Is there something I could change to avoid HTTP 429 (Too Many Requests)? Not sure why this errors shows up as the code isn’t running in a loop:
Here is the full script if needed:
-- Services
local HttpService = game:GetService("HttpService")
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Variables
local Servers = ReplicatedStorage.Servers
-- ID
local JobId = string.split(game.JobId, '-')[1]
local cleanedJobId = string.gsub(JobId , '{', '')
-- Server Region
local serverInfo = HttpService:JSONDecode(HttpService:GetAsync("http://ip-api.com/json/"))
local region = serverInfo.regionName
local country = serverInfo.country
MessagingService:SubscribeAsync("ServerList", function(data)
data = data.Data
if data.serverId ~= cleanedJobId then
local Name = #Servers:GetAttributes() + 1
Servers:SetAttribute(`{Name}`, Name)
Servers.ServersInfo:SetAttribute(`{Name}ID`, `{data.serverId}`)
Servers.ServersInfo:SetAttribute(`{Name}Players`, `{data.players}`)
Servers.ServersInfo:SetAttribute(`{Name}Region`, `{data.serverLocation}`)
Servers.ServersInfo:SetAttribute(`{Name}Place`, `{data.serverPlace}`)
task.wait(5)
Servers:SetAttribute(`{Name}`, nil)
Servers.ServersInfo:SetAttribute(`{Name}ID`, nil)
Servers.ServersInfo:SetAttribute(`{Name}Players`, nil)
Servers.ServersInfo:SetAttribute(`{Name}Region`, nil)
Servers.ServersInfo:SetAttribute(`{Name}Place`, nil)
end
end)
while game.PrivateServerId == "" do
local data = {
serverId = cleanedJobId,
players = #Players:GetPlayers(),
serverLocation = `{region}, {country}`,
serverPlace = game.PlaceId
}
MessagingService:PublishAsync("ServerList", data)
task.wait(5)
end