Hello, so I’m trying to get a game’s likes. For some reason, it’s returning 0. I don’t know why. This is my script:
local HTTPService = game:GetService("HttpService")
local module = {}
function module:GetAssetVotes(AssetType:Enum.AssetType, AssetId:number)
if AssetType == Enum.AssetType.Place then
local Success,Votes = pcall(function()
local AssetVotes = HTTPService:GetAsync("https://games.roproxy.com/v1/games/votes?universeIds=" .. AssetId)
return AssetVotes
end)
if Success and Votes then
return HTTPService:JSONDecode(Votes), HTTPService:JSONEncode(Votes)
end
end
end
return module
This is what it returns:
This is the amount of votes the game has:
Can someone please help? I dont understand whats happening.
UniverseId is not the PlaceId, you need to use a different API to retrieve it using the PlaceId:
local HttpService = game:GetService("HttpService")
function Proxy(url)
return url:gsub("roblox.com", "roproxy.com")
end
function GET(url)
url = Proxy(url)
local result
local Success, Error = pcall(function()
result = HttpService:GetAsync(url)
result = HttpService:JSONDecode(result)
end)
if Success then
return result
else
warn(Error)
end
end
local PlaceId = 0 --your place id
--retrieve UniverseId of PlaceId
local UniverseId = GET("https://games.roblox.com/v1/games/multiget-place-details?placeIds="..PlaceId).universeId
--use it to get the vote details
local AssetVotes = GET("https://games.roblox.com/v1/games/votes?universeIds="..UniverseId)
print(AssetVotes)
I dont know if i’m doing something wrong but this is the error that pops up
this is my script:
local HttpService = game:GetService("HttpService")
function Proxy(url)
return url:gsub("roblox.com", "roproxy.com")
end
function GET(url)
url = Proxy(url)
local result
local Success, Error = pcall(function()
result = HttpService:GetAsync(url)
result = HttpService:JSONDecode(result)
end)
if Success then
return result
else
warn(Error)
end
end
local PlaceId = 7462526249 --your place id
--retrieve UniverseId of PlaceId
local UniverseId = GET("https://games.roblox.com/v1/games/multiget-place-details?placeIds="..PlaceId).universeId
--use it to get the vote details
local AssetVotes = GET("https://games.roblox.com/v1/games/votes?universeIds="..UniverseId)
print(AssetVotes)
I found a fix!! Thanks to what you said about universe ID’s i found a way to get universe ids. And made it get the likes from there! And because of that it worked! This is the script:
local HTTPService = game:GetService("HttpService")
local module = {}
---[Modules]---
---[Checking Modules]--
function module:GetAssetVotes(AssetType:Enum.AssetType, AssetId:number)
if AssetType == Enum.AssetType.Place then
local Success,Votes = pcall(function()
local UniverseId = HTTPService:GetAsync("https://api.roproxy.com/universes/get-universe-containing-place?placeid=" .. AssetId)
UniverseId = string.gsub(UniverseId, "%D", "")
local AssetVotes = HTTPService:GetAsync("https://games.roproxy.com/v1/games/votes?universeIds=" .. UniverseId)
return AssetVotes
end)
if Success and Votes then
return HTTPService:JSONDecode(Votes), HTTPService:JSONEncode(Votes)
else
warn("Something went wrong while fetching asset: " .. AssetId .. "'s votes. " .. Votes)
end
end
end
return module