How do I obtain amount of visist of experience in roblox?

  1. What do you want to achieve? Keep it simple and clear!

I want to obtain amount of visits of game in roblox by Id. So I’m getting place in roblox by MarketPlaceService:GetProduct info, then I check if this product asset type is place. But place info doesn’t have such information, thats why I’m doing this post and because I didn’t found any post about this in devforum.

local HttpService = game:GetService("HttpService");

local Response = HttpService:RequestAsync({
    Method = "GET";
    Url = string.format("https://games.rprxy.xyz/v1/games?universeIds=%d", game.GameId); --// Send to the rprxy.xyz proxy with the current game's id
});

if (Response.Success and Response.Body) then --// If it succeeded, returned a status code of 200-299, and gave a Body
    local Body = HttpService:JSONDecode(Response.Body) --// Turn the JSON string into a Lua table

    if (Body.data[1]) then --// If we got data for our game
        local Visits = Body.data[1].visits;

        --// Logic for using the Visits would go here
    end
end

I got this answer from this post here.

Make sure you enable HTTP service :slight_smile:

Hi there! Thank you for you respond, but it’s fires a 'Can`t parse JSON ’ error.

Url = string.format("https://games.rprxy.xyz/v1/games?universeIds=%d", game.GameId);

Make sure that’s your string, and publish your game. you shouldn’t need to replace anything in in that line of code.

1 Like

I found better solution:

local function GetVisits(Id: number)
	local gameRequest = `https://games.roproxy.com/v1/games?universeIds={Id}`
	local succes, result = pcall(function()
		return HttpService:GetAsync(gameRequest)
	end)
	if succes  then
		local Visit = HttpService:JSONDecode(result).data[1].visits
		return Visit
	end
end

but anyways, thanks for your efforts! :wink:

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.