how i can check and implement checking number to be game id, i dont know how can i do it.(i need function) issue i have, i have id but it always give me assets or something like this, instead of game id
You can achieve this through the games api alongside with an HttpService:GetAsync()
request.
If the “game id” is a placeId use this endpoint:
https://games.roblox.com/v1/games/multiget-place-details?placeIds={PlaceID}
If the “game id” is a universeId use this one instead:
https://games.roblox.com/v1/games?universeIds={UniverseID}
Then simply check if there is a game data that was returned or not.
An alternate way you can do this is using MarketPlaceService:GetProductInfo()
but that is a less reliable option and has a stricter rate limit than http service calls.
what you mean games have universeid? and i dont get i can check if game id is this number through checking this in url?
What are you trying to accomplish here (I might have gotten it wrong)? I meant is the “gameid” the PlaceId or the UniverseId of a roblox game, seems like it is the PlaceId from your response.
i wanna check if number i generated is game id not asset or something else
That is what I am trying to say? Could you please read my response above again for the solutions.
local MarketplaceService = game:GetService("MarketplaceService")
local function IsGameId(id)
local success, info = pcall(function() return MarketplaceService:GetProductInfo(id) end)
return success and info and info.AssetTypeId == 9
end
print(IsGameId(1234567))
Returns True if so …
i readed i dont get it because you said if id is place id and if it universe id i dont understand how one number can be universe id and place id
Ok, there is two possible ways for this:
You can either use httpservice (from the server) for this, which should look like this:
local httpservice = game:GetService("HttpService")
local placeId = 123213123 -- change this to your random game id
local success, result = pcall(function()
return httpservice:GetAsync("https://games.roproxy.com/v1/games/multiget-place-details?placeIds=" .. placeId)
end)
if not success then
error("Failed:" .. (result or ""))
end
if success and result then
print(httpservice:JSONDecode(result))
end
Or Instead use MarketplaceService, which should look like this:
local MarketplaceService = game:GetService("MarketplaceService")
local placeId = 123213123 -- change this to your random game id
local success, result = pcall(function()
return MarketplaceService:GetProductInfo(placeId)
end)
if success and result then
if result.AssetTypeId == 9 then
print(result)
end
end
why you using typeId == 9???
AssetTypeId 9 is the assettype for games.
http always give me error even if its game
HttpService can only be used from the Server, if you are using it from the client it is incorrect. You should also check if HttpService requests are enabled in Game Settings → Security, if you are checking it from the client go with the GetProductInfo method but it has stricter rate limits.
i doing this in legacy script in ServerScriptService
Is HttpServiceRequests enabled in Game Settings → Security
yes! it is enabled in game settings
Hmm could you print out the result / the given error.
Failed:HTTP 401 (Unauthorized)
Ah my bad, I always use UniverseId and didn’t know multiget-place-details had a restriction. Could you try using MarketplaceService:GetProductInfo()
with one of the examples provided above.
yes its working fine but its work one time only