I wanted to ask if its possible to create a game id with random nubmers and then print the game name? and if I would want to add so that you could join that game then would it be allowed? like is it allowed to do something like that in roblox or not? and is it even possible to do something like that?
As far as the game name:
local name = game:GetService("MarketplaceService"):GetProductInfo(GAME_ID).Name
As far as “could you join that game”: that would depend on how they set it up. If it was full public I’m sure you could.
local gameId = math.random(1000000000, 9999999999) -- Generate a random game ID
local gameInfo = game:GetService("MarketplaceService"):GetProductInfo(gameId, Enum.InfoType.Game)
if gameInfo then
print("Game Name:", gameInfo.Name)
else
print("Game not found.")
end
Please note that generating a random game ID does not guarantee that the game exists. The GetProductInfo function will return nil if the game with the specified ID does not exist.
I have a question about “Enum.InfoType.Game”. does infotype.game exsist? cause I cant find it
No.
im on my phone so i just wrote example
so nothing like that exists? or like is there any way to sort them?
while wait(3) do
local gameId = math.random(m,m) -- Generate a random game ID
local gameInfo = game:GetService("MarketplaceService"):GetProductInfo(7041939546)
if gameInfo then
print("Game Name:", gameInfo.Name)
print(gameId)
else
print("Game not found.")
end
end
Here you go this works, just change the 7041939546 with you random number
Is there also a way to get the player amount across all servers with that method?
okay, I fould this AssetType | Documentation - Roblox Creator Hub and I just did if gameinfo.AssetTypeId == 9 then
– here is the other part of the script
Mark it as a solution if i helped it will be my first one <3
I don’t want to mark anyone as solution. cause I can mark only 1 person. but you and 2112jay helped both. and I don’t want only one just have it.
I mean he has 106 solutions already so I maybe can give it to you idk
local gameInfo=game:GetService("MarketplaceService"):GetProductInfo(gameId, Enum.InfoType.Game)
Comes out as … Game is not a valid member of “Enum.InfoType”
local gameInfo=game:GetService("MarketplaceService"):GetProductInfo(gameId)
Comes out with a table holding the game information.
What you’re looking for is: (with a random number of course)
local gameInfo=game:GetService("MarketplaceService"):GetProductInfo(gameID)
local gameName=(gameInfo["Name"])
print(gameName)
You may also call a asset with a random number and not a game.
This is how you can check for that…
local assetId = "gameID"
local MarketplaceService = game:GetService("MarketplaceService")
local productInfo = MarketplaceService:GetProductInfo(assetId)
if productInfo and productInfo.AssetTypeId == 9 then
print("Asset is a game")
else print("Asset is not a game")
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.