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

How to get the visit count of a place by ID?

Asked by 3 years ago

So I have a game where it picks a random number from 1 to 1,000,000,000 and sends the player to that place's ID if it exists. The game works fine, but I was wondering if there was a way to tell if the place has at least 100 visits. This is so that we don't keep on getting sent to starter places.

1 answer

Log in to vote
0
Answered by
9mze 193
3 years ago

here is a little function for finding a few stuff from the game page.

function players_online(place_id)
    local web = game.HttpService:GetAsync("https://www.rprxy.xyz/games/"..place_id)
    local player_text = string.find(web,"Created") -- ("Visits", "Favorites", "Playing", "Created", "Updated") find the online players section
    local new = string.sub(web,player_text)

    local number_start = string.find(new,">") -- find where the number starts
    new = string.sub(new,number_start)

    local number_end = string.find(new,"<") -- find where the number ends
    new = string.sub(new,2,number_end-1)

    local players_online = string.gsub(new,",","") -- in case it's over 1000 players
    return players_online
end

print(players_online(2180488865))
Ad

Answer this question