How do i check that an asset is a Game and not a Model or something like that?

Im making a wayback machine game where you can quicky teleport to old games, and i’m halfway done with it. I have the ID validation, GUI’s and teleportation all figured out. When i request a new game, sometimes i get an asset not a game. Is there a way to check if it’s a game? Any type of help is appreciated.

Here are the scripts i made so far:

server script

local MPS = game:GetService("MarketplaceService")
local information
local event = game.ReplicatedStorage.event

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		char.Humanoid.WalkSpeed = 0
		char.Humanoid.JumpHeight = 0
	end)
end)

local id = math.random(200, 5000)

local success, error = pcall(function()
	information = MPS:GetProductInfo(id)
end)

if success then
	print(information.Name)
	local title = information.Name
	local image = "rbxthumb://type=Asset&id="..information.AssetId.."&w=150&h=150"
	event:FireAllClients(title, image)
else
	print(error)
end

local script

local event = game:GetService("ReplicatedStorage").event

event.OnClientEvent:Connect(function(title, image)
	script.Parent.TextLabel.Text = title
	script.Parent.ImageLabel.Image = image
end)

By the way, my temporary solution is requesting a new game. Don’t think its relevant though, because my goal is to make only games show up.

1 Like
local MarketplaceService = game:GetService("MarketplaceService")
local assetId = "gameID"
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

Thank you so much, this saved my project.

2 Likes

That’s great … I’ve sure had a few of them over the years. Chat sure saved me. GL!

1 Like