Is There A way to make like a button script so when you click a button it will find a random user on roblox that owns a Certain Asset From The Catalog And it will print it out in the console…???
You can use the endpoint to check a player’s inventory:
https://inventory.roblox.com/v1/users/{userId}/items/Asset/{itemId}
As of right now there is no way for you to access the owners of another person’s asset so I don’t think there is any easy way of doing this.
but you cant acess ROBLOX Api on roblox
This is probably the only option. It’s module script so you can use it in any script.
local HttpService = game:GetService("HttpService")
local maxPlayer = 7343000000
local http = nil
local response = nil
local number = nil
local random = nil
local itemFinder = {}
function itemFinder.find(assetId)
while true do
number = HttpService:GetAsync("https://www.randomnumberapi.com/api/v1.0/random?min=1&max=" .. maxPlayer)
random = number:sub(2,-3)
local success = pcall(function()
http = HttpService:GetAsync("https://inventory.roproxy.com/v1/users/" .. random .. "/items/Asset/" .. assetId)
response = HttpService:JSONDecode(http)
if #response.data == 0 then
error()
end
end)
if success then
print(random)
break
end
end
end
return itemFinder
How to use module script?
First, create a script in ServerScriptService (does not work in LocalScript) or ReplicatedStorage (if you want it to work in localscript, less secure) and paste the code above there
Then add this to your script at top (will not work in localScript):
local ServerScriptService = game:getService("ServerscriptService")
local itemFinder = require(ServerScriptService.itemFinder)
or if you want the script to run in localScript, (less safe):
local ReplicatedStorage = game:getService("ReplicatedStorage")
local itemFinder = require(ReplicatedStorage.itemFinder)
Then use the function:
itemFinder.find(itemId)
This will give you a random player id. Remember to replace the itemId with a real item ID.
I used randomnumberapi.com because math.random() has a limitation and won’t handle such large numbers and roproxy becaouse it’s good proxy (roblox.com is blocked in studio). If you want to use this, remember to enable HTTP requests in the game settings → Security. This solution may not always work due to limitations in the number of API requests and HTTP requests. (I’m not sure how many requests you can make or if there are any limitations at all) . When you reach the API/HTTP request limit the script will most likely have an error in response.data or the request will return an error code so the loop will not stop and will continue searching. While doesn’t execute very quickly so it takes a while to find the player.
Don’t forget to update the maxPlayer variable sometimes (total number of accounts on roblox) for the script to work with new accounts.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.