alright so, what i’ve made is whenever you click this certain part, it searches for random ids on roblox until it finds a valid one, then you’re able to buy whatever the id was (like it prompts up the hat with that id). however, i’ve encountered a problem. i think somethings wrong with the code, it just keeps searching, and not a single id is valid. also it’s very slow but that’s a different problem. scripting is not my suite ;-;
it’s also good to mention that no errors pop up.
local part = game.Workspace.clearance_bin_hat:WaitForChild("random_hat_click_part")
local clickDetector = part:FindFirstChildOfClass("ClickDetector")
local debounce = true
local framevisible = false
local sgui = script.Parent
if not clickDetector then
clickDetector = Instance.new("ClickDetector", part)
end
local function isValidShirtId(shirtId)
local success, response = pcall(function()
return game:GetService("MarketplaceService"):GetProductInfo(shirtId)
end)
return success and response and response.AssetTypeId == 8 and response.PriceInRobux and response.PriceInRobux > 0
end
local function promptPurchase(player, shirtId)
game:GetService("MarketplaceService"):PromptPurchase(player, shirtId)
end
clickDetector.MouseClick:Connect(function(player)
if debounce == true then
debounce = false
sgui.Visible = not sgui.Visible
game.SoundService.Click:Play()
local max = 1.6e11
local ran = Random.new()
local shirtId = ran:NextNumber(1, max)
while not isValidShirtId(shirtId) do
shirtId = ran:NextNumber(1, max)
task.wait(0.01)
end
print("found valid hat id!:"..shirtId)
promptPurchase(player, shirtId)
task.wait(1)
sgui.Visible = false
debounce = true
end
end)