Live Visits Counter

I am trying to make a game where it displays a different games visit count and it auto updates how would I do this?

1 Like

To make a game in Roblox that displays a visit count and updates it automatically, you will need to use the Data Store feature.

Here is an example of how you could set this up:

  1. First, you will need to create a Data Store in the Roblox Studio. To do this, go to the Insert tab and click on the Data Store icon. This will add a Data Store object to your game.
  2. Next, you will need to name your Data Store and give it a unique ID. This can be any string of letters and numbers that you choose.
  3. Once your Data Store is set up, you can use it to store and retrieve the visit count for your game. To do this, you will need to use the “GetAsync” and “IncrementAsync” functions of the Data Store object.

Here is an example of how you could use these functions to display the visit count for your game:

local DataStore = game:GetService("DataStoreService"):GetDataStore("MyDataStore")

local function updateVisitCount()
    local currentVisitCount = DataStore:GetAsync("visitCount")
    if not currentVisitCount then
        currentVisitCount = 0
    end
    currentVisitCount = currentVisitCount + 1
    DataStore:SetAsync("visitCount", currentVisitCount)
end

updateVisitCount()

local visitCountText = Instance.new("TextLabel")
visitCountText.Text = "Visit Count: " .. currentVisitCount
visitCountText.Parent = game.Workspace

This code will retrieve the current visit count from the Data Store, increment it by 1, and then update the value in the Data Store. It will also create a text label that displays the visit count.

Note that the visit count will only be updated when the game is run on the Roblox servers, not when it is run locally in the Roblox Studio.

I don’t need that I need something that can grab the visit count from a another game not the same game.

I don’t believe there is an api for this, and while I don’t recommend this, you could try web scrapping, however I do not know if it is against ToS, still waiting for an answer from a mod on that.

There’s an api for this, which is https://games.roblox.com/v1/games?universeIds=UNIVERSE_ID
You need to use a proxy like roproxy in order to request this in roblox

You can make a GET request with this and get the visits count:

local httpService = game:GetService("HttpService")

local success, json = pcall(function()
     return httpService:GetAsync("https://games.roproxy.com/v1/games?universeIds=UNIVERSE_ID")
end)

if success then
     local response = httpService:JsonDecode(json)
     local visits = response.data[1].visits
      print("visit count: "..visits)
end

if you need help getting the universe id, there’s also an api for that http://api.roblox.com/universes/get-universe-containing-place?placeid=PLACE_ID

Here’s an example on how to use it:

local httpService = game:GetService("HttpService")
local url = "http://api.roblox.com/universes/get-universe-containing-place?placeid=%s"

local success, response = pcall(function()
     return httpService:GetAsync(url:format("PLACE_ID")
end)

if success then
    local universeId = httpService:JsonDecode(response).UniverseId
    print("universeId: "..universeId)
end

Sorry for the bad formatting since im on mobile.

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