I’ve noticed games that award UGC limiteds by completing a certain goal. One thing I’ve consistently seen is a badge awarded, followed by being awarded the item. My issue is that I can’t find any documentation on this whatsoever. The closest I can find is getting the item to only be sold in-game and then prompting a purchase, but that isn’t really the same thing and can be exploited client-side.
Could anyone reference any documentation regarding awarding UGC limiteds in-game?
You were on the right track with prompting for purchase, and PromptPurchase() is exactly what you will use to award UGC limiteds in your game, but this can only be done from server side. As the method description follows:
If prompting a purchase of a Limited item, the request must come from the server or the purchase fails.
Below is a code example to help you get going in the right direction.
-- ServerScript
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local BadgeService = game:GetService("BadgeService")
local ugcId, badgeId = 0000000, 999999999
local function awardBadge(plr, badgeId)
local success, badgeInfo = pcall(function()
return BadgeService:GetBadgeInfoAsync(badgeId)
end)
if success and badgeInfo.Enabled then
local awarded, result = pcall(function()
return BadgeService:AwardBadge(plr.UserId, badgeId)
end)
if not awarded then
warn("Something went wrong while awarding BadgeID "..badgeId..": "..result)
end
else
warn("Couldn't retrieve BadgeInfo for BadgeID "..badgeId)
end
end
Players.PlayerAdded:Connect(function(plr)
MarketplaceService:PromptPurchase(plr, ugcId)
end)
MarketplaceService.PromptPurchaseFinished:Connect(function(plr, productId, purchased)
if purchased and productId == ugcId then
awardBadge(plr, badgeId)
end
end)
Ah, so the badge thing was just coincidental then. I didn’t realize that limiteds could only be prompted server-side, so I guess that solves it then. Thank you for your response