How Do I Show My Place Visits In Game

Hello, CoolSpaace Here. So I want to make a GUI or surface GUI that shows the places visits. Better Example: Some one joins your game and your game visits go up then in your game the text label(GUI or surface UI) shows the exact amount. Please help me I think it has to do with API but I dont understand it. Thanks… If this helps image thats what I want to show in game

4 Likes

Yep, you can do this with one of Roblox’s API - specifically the /v1/games endpoint. Now you’ll need a proxy, such as rprxy.xyz, to access this as Roblox do not allow HttpService’s requests to be sent to one of Roblox’s domains.

You’ll want to send a GET request to the endpoint and select the 1st input of the data array inside the body of the response (which’ll need to be JSONDecoded). A query can be used to select which game(s) you want to get the details of.

Now as an example, we’ll use the GameId:

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;

        --// Do what you need to
    end
end

Tell me how it goes!

6 Likes

Wait so would this be in a script or local script?

Only Scripts can perform HTTP requests, you’ll probably want to integrate a RemoteFunction for the client to InvokeServer and let the server execute a request and return the visits.

1 Like

Also where would i put my roblox id in this “https://games.rprxy.xyz/v1/games?universeIds=%d”. Sorry I just have alot of questions since ive never done this before

or game id…

%d (string format for digit) is currently being formatted by game.GameId, you can replace that by your id.

1 Like

Dude your a legend THANKS SO MUCH :smiley:

2 Likes

I plan on making a system similar to this for a game analytics place i’m working on. What changes would I need to make to make it work correctly as i’ve tried and couldn’t get it to work.