Hi, I am making a game which requires me to change the place id of another game into a universe id. Is there anyway proxy I can use to do this? It is urgent as this is the main mechanic of my game.
Here’s the code I came up with:
local HttpService = game:GetService("HttpService")
local function getUniverseId(placeId)
local url = `https://apis.roproxy.com/universes/v1/places/{placeId}/universe`
local result = HttpService:GetAsync(url)
return HttpService:JSONDecode(result).universeId
end
local success, universeId = pcall(getUniverseId, game.PlaceId)
print(universeId)
print(game.GameId)
print(universeId == game.GameId) --> true
still doesn’t work, basically my whole code has errors,
–// Type Definitions.
type Array = {[number] : Type};
type Dictionary = {[string] : Type};
–// Plugin Initalization.
local DataFetcher = {};
local HttpService = game:GetService(“HttpService”)
local MarketplaceService = game:GetService(“MarketplaceService”)
local UniverseFetchRootUrl = “https://apis.roproxy.com/universes/v1/places/%s/universe”
local GamepassFetchRootUrl = “https://games.roproxy.com/v1/games/%s/game-passes?sortOrder=Asc&limit=100”
local GamepassFetchAltUrl = “https://inventory.roproxy.com/v2/users/%s/inventory?assetTypes=GamePass&limit=100&sortOrder=Asc”
local GamesFetchRootUrl = “https://games.roproxy.com/v2/users/%s/games?sortOrder=Asc&limit=50”
–// Plugin Actions.
function DataFetcher:GetUniverseIdFromPlaceId(PlaceId)
local Url = UniverseFetchRootUrl:format(PlaceId)
local OperationSuccessful = false
local UserFrontfacingMessage = “”
local UniverseId = nil
local ReturnData = nil
local Success, ErrorMessage = pcall(function()
ReturnData = HttpService:GetAsync(Url)
end)
if Success then
if ReturnData then
local FormattedReturnData = HttpService:JSONDecode(ReturnData)
if FormattedReturnData.errors then -- 'errors' key is lowercase in Roblox API
local Error = FormattedReturnData.errors[1]
UserFrontfacingMessage = Error.message
warn(Error.message)
else
OperationSuccessful = true
UniverseId = FormattedReturnData.universeId -- Correct key
end
else
UserFrontfacingMessage = "There was an error. Try again!"
warn("No return data in fetching universe ID")
end
else
UserFrontfacingMessage = "There was an error. Try again!"
warn("No success in fetching universe ID")
warn(ErrorMessage)
end
return OperationSuccessful, UserFrontfacingMessage, UniverseId
end
function DataFetcher:GetGamepassesFromUniverseId(UniverseId)
local Url = GamepassFetchRootUrl:format(UniverseId)
local OperationSuccessful = false
local UserFrontfacingMessage = “”
local Gamepasses = nil
local ReturnData = nil
local Success, ErrorMessage = pcall(function()
ReturnData = HttpService:GetAsync(Url)
end)
if Success then
if ReturnData then
local FormattedReturnData = HttpService:JSONDecode(ReturnData)
if FormattedReturnData.Errors then
local Error = FormattedReturnData.Errors[1]
UserFrontfacingMessage = Error.message
warn(Error.message)
else
OperationSuccessful = true
local GamepassData = FormattedReturnData.data
Gamepasses = {}
for _, GamepassInfo in GamepassData do
if GamepassInfo.price and GamepassInfo.price > 0 then
Gamepasses[#Gamepasses + 1] = {
Id = GamepassInfo.id,
Name = GamepassInfo.displayName,
Price = GamepassInfo.price,
}
end
end
end
else
UserFrontfacingMessage = "There was an error. Try again!"
warn("No return data in fetching gamepasses")
end
else
UserFrontfacingMessage = "There was an error. Try again!"
warn("No success in fetching gamepasses")
warn(ErrorMessage)
end
return OperationSuccessful, UserFrontfacingMessage, Gamepasses
end
function DataFetcher:GetGamesFromPlayer(Player)
local UserId = Player.UserId
local Url = GamesFetchRootUrl:format(UserId)
local OperationSuccessful = false
local UserFrontfacingMessage = “”
local Games = nil
local ReturnData = nil
local Success, ErrorMessage = pcall(function()
ReturnData = HttpService:GetAsync(Url)
end)
if Success then
if ReturnData then
local FormattedReturnData = HttpService:JSONDecode(ReturnData)
if FormattedReturnData.Errors then
local Error = FormattedReturnData.Errors[1]
UserFrontfacingMessage = Error.message
warn(Error.message)
else
OperationSuccessful = true
local GameData = FormattedReturnData.data
Games = {}
for _, GamepassInfo in GameData do
Games[#Games + 1] = GamepassInfo.id
end
end
else
UserFrontfacingMessage = "There was an error. Try again!"
warn("No return data in fetching games")
end
else
UserFrontfacingMessage = "There was an error. Try again!"
warn("No success in fetching games")
warn(ErrorMessage)
end
return OperationSuccessful, UserFrontfacingMessage, Games
end
function DataFetcher:GetGamepassesFromPlayer(Player)
local Success, Error, Games = self:GetGamesFromPlayer(Player)
if not Success then
return Success, Error, nil
end
local AllGamepasses = {}
for _, GameId in Games do
local Success, Error, Gamepasses = self:GetGamepassesFromUniverseId(GameId)
if not Success then
return Success, Error, nil
end
for _, GamepassInfo in Gamepasses do
table.insert(AllGamepasses, GamepassInfo)
end
end
return true, "", AllGamepasses
end
–// Plugin Finalization.
return (DataFetcher);
sorry for the bad formatting, forgot to do it properly
You can edit your messages. Format using
(Uses the symbol `)
What errors?