Essentially, this code is designed to establish a webhook connection between Roblox and Discord, allowing it to notify Discord about the in-game purchases made by players. However, currently, it only functions properly when a test purchase of developer items is made within the Roblox studio. How can I modify it to work for various types of purchases, including game passes, developer IDs, and other items and make it work in actual game, not only roblox studio?
(code is not mine)
HTTPService = game:GetService("HttpService")
Webhook_URL = ''
game.Players.PlayerAdded:Connect(function(player)
MarketplaceService.PromptProductPurchaseFinished:Connect(function(userid, id, ifpurchased1)
if ifpurchased1 then
local Data = {
["content"] = "",
["embeds"] = {{
["title"] = "**New Product Purchase**" ,
["description"] = player.Name .. " **Has Purchased: ** ".. MarketplaceService:GetProductInfo(id, Enum.InfoType.Product).Name, -- Change Robux Amount to how much product was worth
["type"] = "rich",
['url'] = "https://www.roblox.com/users/".. player.UserId .. "/profile",
["color"] = 4972305,
["fields"] = {
{
["name"] = " Product Price ",
["value"] = MarketplaceService:GetProductInfo(id, Enum.InfoType.Product).PriceInRobux .. " Robux",
["inline"] = true
},
{
['name'] = "User ID: ",
['value'] = userid,
['inline'] = true
}
}
}}
}
Data = HTTPService:JSONEncode(Data)
HTTPService:PostAsync(Webhook_URL, Data)
end
end)
end)