Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to I check if an ID init64 is a valid PlaceID?

Asked by
uhTeddy 101
6 years ago

If there is a possible way for a script to see if a number init64 is a valid PlaceID please let me know because it is needed.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
function IsGameValid(id)
local isgame
    local success,message = pcall(function()
    local gameid = game:GetService('MarketplaceService'):GetProductInfo(id) 
isgame = gameid.AssetTypeId == 9
    end)
  return success and isgame
end 

This function returns whether the given ID is a game. If you wanted to do something if this is true then you would do this:

if IsGameValid(1) then --Change 1 to an ID.
--Code here
end

Hope this helped!

0
Sorry, forgot to make the function check if it was a game. I edited my answer so now it should work properly. brokenVectors 525 — 6y
Ad

Answer this question