local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetProduct = ReplicatedStorage:FindFirstChild("GetProduct")
local HttpService = game:GetService("HttpService")
local lastRequest = {}
local requestInterval = 3
local minPrice = 1
local maxPrice = -1
local universeId = game.GameId
local productCache = {}
local requestUrl = game.ServerStorage:FindFirstChild("baseRequestUrl").Value .. "/addProduct"
local auth = "PutYourCustomAuthHere"
function requestProduct(price)
local res = HttpService:RequestAsync({
Url = requestUrl;
Method = "POST";
Headers = {
["Content-Type"] = "application/json",
["Authorization"] = auth
};
Body = HttpService:JSONEncode({
["universeId"] = universeId;
["placeId"] = game.PlaceId;
["price"] = price;
});
})
return res
end
GetProduct.OnServerInvoke = function(player, amount)
local requestTime = tick()
if lastRequest[player.UserId] and requestTime-lastRequest[player.UserId] < requestInterval then
return "Requested too fast, please wait longer between requests"
end
lastRequest[player.UserId] = requestTime
local price = tonumber(amount)
if not price then
return "Supplied price must be a number"
elseif price < minPrice then
return "Supplied price must be at least "..tostring(minPrice)
elseif maxPrice > minPrice and price > maxPrice then
return "Supplied price must less than "..tostring(maxPrice)
elseif productCache[price] then
return productCache[price]
else
price = math.ceil(price)
local res = requestProduct(price)
if res.Success then
local body = HttpService:JSONDecode(res.Body)
productCache[price] = body.productId
return body.productId
else
warn(HttpService:JSONEncode(res))
return "Something went wrong, try again later or with a different amount"
end
end
end
It has long been known that you can not access roblox resources using HTTPService. It is deliberate on Roblox’s end. If you wish, you can use a thirdparty proxy, but that is more effort and can be costly.
It is not possible to create dev products. What games do when they wish to have dynamic sales (devproducts give increasing amounts, etc…) is have a bunch of pre-made ones, then an algorithm that just changes how much ‘money’ or whatever it is the player is given on the purchase of that set price
This stuff is wrong. Ignore it
Based on what you are trying to achieve, can I suggest you have a look at MarketPlaceService instead, specifically GetProductInfo
Not sure;
check the actual Roproxy devforum post for information iG
(Also, ScriptingSupport post requirements dictate that for future questions, you create a new post, as your original question has been solved [make sure to make it as solved btw])