Can someone help me with bundle functionality as well, since they don’t work with getproductinfo?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local function AsyncWrapper(asyncFunc, ...)
local args = {...}
local success, result = pcall(asyncFunc, table.unpack(args))
if success then return result end
warn("AsyncWrapper: "..result)
end
local NotifierEvent = Instance.new("RemoteEvent")
NotifierEvent.Name = "NotifierEvent"
NotifierEvent.Parent = ReplicatedStorage
MarketplaceService.PromptPurchaseFinished:Connect(function (player, assetId, wasPurchased)
if not wasPurchased then return end
print(tostring(player))
print(tostring(assetId))
print(tostring(wasPurchased))
local assetInfo = AsyncWrapper(MarketplaceService.GetProductInfo, MarketplaceService, assetId)
if assetInfo then
NotifierEvent:FireAllClients(player.Name, assetInfo.Name, assetInfo.PriceInRobux)
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local function AsyncWrapper(asyncFunc, ...)
local args = {...}
local success, result = pcall(asyncFunc, table.unpack(args))
if success then return result end
warn("AsyncWrapper: "..result)
end
local NotifierEvent = Instance.new("RemoteEvent")
NotifierEvent.Name = "NotifierEvent"
NotifierEvent.Parent = ReplicatedStorage
MarketplaceService.PromptPurchaseFinished:Connect(function (player, assetId, wasPurchased)
if not wasPurchased then return end
print("Purchase finished for player: " .. tostring(player))
print("Purchased assetId: " .. tostring(assetId))
print("Was purchased: " .. tostring(wasPurchased))
local assetInfo = AsyncWrapper(MarketplaceService.GetProductInfo, MarketplaceService, assetId)
if assetInfo then
if assetInfo.PriceInRobux then
print("Price in Robux: " .. assetInfo.PriceInRobux)
else
print("Price in Robux: N/A")
end
NotifierEvent:FireAllClients(player.Name, assetInfo.Name, assetInfo.PriceInRobux)
print("NotifierEvent fired with details:")
print("Player: " .. player.Name)
print("Asset Name: " .. assetInfo.Name)
else
print("Failed to retrieve asset info for assetId: " .. tostring(assetId))
end
end)
MarketplaceService.PromptBundlePurchaseFinished:Connect(function (player, assetId, wasPurchased)
if not wasPurchased then return end
print("Bundle purchase finished for player: " .. tostring(player))
print("Purchased bundle assetId: " .. tostring(assetId))
print("Was purchased: " .. tostring(wasPurchased))
local assetInfo = AsyncWrapper(MarketplaceService.GetProductInfo, MarketplaceService, assetId, 4) -- Assuming 4 is the correct infoType for bundles
if assetInfo then
if assetInfo.PriceInRobux then
print("Price in Robux: " .. assetInfo.PriceInRobux)
else
print("Price in Robux: N/A")
end
NotifierEvent:FireAllClients(player.Name, assetInfo.Name, assetInfo.PriceInRobux)
print("NotifierEvent fired with details:")
print("Player: " .. player.Name)
print("Bundle Name: " .. assetInfo.Name)
else
print("Failed to retrieve asset info for bundle assetId: " .. tostring(assetId))
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local AvatarEditorService = game:GetService("AvatarEditorService")
local NotifierEvent = Instance.new("RemoteEvent")
NotifierEvent.Name = "NotifierEvent"
NotifierEvent.Parent = ReplicatedStorage
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, wasPurchased)
if not wasPurchased then return end
print("Purchase finished for player: " .. tostring(player))
print("Purchased assetId: " .. tostring(assetId))
print("Was purchased: " .. tostring(wasPurchased))
local assetInfo = MarketplaceService:GetProductInfo(assetId, Enum.InfoType.Asset)
if assetInfo then
if assetInfo.PriceInRobux then
print("Price in Robux: " .. assetInfo.PriceInRobux)
else
print("Price in Robux: N/A")
end
NotifierEvent:FireAllClients(player.Name, assetInfo.Name, assetInfo.PriceInRobux)
print("NotifierEvent fired with details:")
print("Player: " .. player.Name)
print("Asset Name: " .. assetInfo.Name)
else
print("Failed to retrieve asset info for assetId: " .. tostring(assetId))
end
-- Check if purchased item is a bundle
local itemType = AvatarEditorService:GetItemDetails(assetId, Enum.AvatarItemType)
if itemType and itemType.ItemType == Enum.AvatarItemType.Bundle then
-- Handle bundle purchase
local bundleName = itemType.Name
local bundlePrice = itemType.PriceInRobux or "N/A"
print("Bundle purchased: " .. bundleName)
print("Price in Robux: " .. bundlePrice)
NotifierEvent:FireAllClients(player.Name, bundleName, bundlePrice)
print("NotifierEvent fired for bundle with details:")
print("Player: " .. player.Name)
print("Bundle Name: " .. bundleName)
else
print("Item purchased is not a bundle.")
end
end)
Instaad of PriceInRobux, it should be Price as that’s what the price is defined as in the dictionary returned.
Additionally, why not just use MarketplaceService.PromptBundlePurchaseFinished for bundles instead of checking if a purchased asset is a bundle through MarketplaceService.PromptPurchaseFinished?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local AvatarEditorService = game:GetService("AvatarEditorService")
local function AsyncWrapper(asyncFunc, ...)
local args = {...}
local success, result = pcall(asyncFunc, table.unpack(args))
if success then return result end
warn("AsyncWrapper: "..result)
end
local NotifierEvent = Instance.new("RemoteEvent")
NotifierEvent.Name = "NotifierEvent"
NotifierEvent.Parent = ReplicatedStorage
MarketplaceService.PromptPurchaseFinished:Connect(function (player, assetId, wasPurchased)
if not wasPurchased then return end
print(tostring(player))
print(tostring(assetId))
print(tostring(wasPurchased))
local assetInfo = AsyncWrapper(MarketplaceService.GetProductInfo, MarketplaceService, assetId)
if assetInfo then
NotifierEvent:FireAllClients(player.Name, assetInfo.Name, assetInfo.PriceInRobux)
end
end)
MarketplaceService.PromptBundlePurchaseFinished:Connect(function(player, bundleId, wasPurchased)
if not wasPurchased then return end
print(tostring(player))
print(tostring(bundleId))
print(tostring(wasPurchased))
local assetInfo = AvatarEditorService:GetItemDetails(bundleId, Enum.AvatarItemType.Bundle)
if assetInfo then
NotifierEvent:FireAllClients(player.Name, assetInfo.Name, assetInfo.Price)
end
end)