#Is it possible to check if a person has bought a item such as clothing or UGC from inside my game.

1 messages · Page 1 of 1 (latest)

earnest robin
#

Little confused.

#

Is it possible to check if a person has bought a item such as clothing or UGC from inside my game. Can I detect that and make it ping something else or use it for something else? All im finding is that i can detect gamepasses and dev products.

bold dune
#

Yes you can

dawn bay
#

maybe data stores?

void jay
#

log their purchases

wooden salmon
# earnest robin Is it possible to check if a person has bought a item such as clothing or UGC fr...
local MarketPlaceService = game:GetService("MarketplaceService");

local TargetID = 15630817253; -- change to your id

MarketPlaceService.PromptPurchaseFinished:Connect(function(Player,ProductId,WasPurchased)
    if WasPurchased and ProductId == TargetID then
        print(Player.Name.." purchased a UGC or clothing Item.");
    end
end)

--[[game.Players.PlayerAdded:Connect(function(plr) -- test
    task.wait(1);
    MarketPlaceService:PromptPurchase(plr,TargetID);
end)--]]```
earnest robin
#

maybe im doing it wrong

wooden salmon
#

Make sure your using PromptPurchase and PromptPurchaseFinished

and not
PromptProductPurchase
PromptGamePassPurchase

earnest robin
#
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LogPurchaseToDiscord = ReplicatedStorage:WaitForChild("LogPurchaseToDiscord")
local player = game.Players.LocalPlayer

MarketplaceService.PromptPurchaseFinished:Connect(function(userId, assetId, isPurchased)
    if isPurchased and userId == player.UserId then
        print("✅ Real purchase confirmed:", assetId)

        local success, info = pcall(function()
            return MarketplaceService:GetProductInfo(assetId)
        end)

        if success then
            LogPurchaseToDiscord:FireServer("Purchased: " .. info.Name .. " for " .. (info.PriceInRobux or "?") .. " Robux", assetId)
        end
    end
end)
stuck latchBOT
#

studio** You are now Level 6! **studio

earnest robin
#

@wooden salmon

#

This wasnt working for UGC or Avatar items

#

so is the bottom part of your script what makes it work?

#

well no its just

#

a promot

#

prompt

wooden salmon
#

give me a second

earnest robin
#

All good thank you

#

i was working on this at like 4 am so

#

its prob shit LOL

wooden salmon
#

userId returns an Instance value being the player who purchased the product. Hence why the script doesn't continue further

wooden salmon
# earnest robin All good thank you
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LogPurchaseToDiscord = ReplicatedStorage:WaitForChild("LogPurchaseToDiscord")
local player = game.Players.LocalPlayer

MarketplaceService.PromptPurchaseFinished:Connect(function(purchasedPlayer, assetId, isPurchased)
    if isPurchased and purchasedPlayer.UserId == player.UserId then
        print("✅ Real purchase confirmed:", assetId)

        local success, info = pcall(function()
            return MarketplaceService:GetProductInfoAsync(assetId,Enum.InfoType.Asset);
        end)

        if success then
            LogPurchaseToDiscord:FireServer("Purchased: " .. info.Name .. " for " .. (info.PriceInRobux or "?") .. " Robux", assetId)
        end
    end
end)```
wooden salmon