#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)
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.
Yes you can
maybe data stores?
log their purchases
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)--]]```
So in my testing this ONLY worked for gamepasses and developer products
maybe im doing it wrong
place the script into ServerScriptService and uncomment the test bit. It should work
Make sure your using PromptPurchase and PromptPurchaseFinished
and not
PromptProductPurchase
PromptGamePassPurchase
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)
** You are now Level 6! **
@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
theres slight misunderstanding on your script. Also you shouldn't track this purchase on the client and send it to the server
give me a second
userId returns an Instance value being the player who purchased the product. Hence why the script doesn't continue further
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)```
ill try this when im on next
alright, remember to try move this event to the server. Exploiters can tamper with the remote sending fake information which your webhook will send to your discord server