Hello everyone,
recently I have been working on an Obby game. And I want to give players a badge after they buy a specific Developer Product. I tried searching this script everywhere, but I couldn’t find it. Can anyone help me with that, please?
Ok thank you, it’s a very useful tutorial
local MS = game:GetService("MarketplaceService")
local BadgeService = game:GetService("BadgeService")
local GamepassId = 0 -- Change to your gamepass id
local BadgeId = 1 -- Change to your badge id
game.Players.PlayerAdded:Connect(function(Player)
while wait() do
if MS:UserOwnsGamePassAsync(Player , GamepassId) then
BadgeService:AwardBadge(Player , BadgeId)
elseif BadgeService:UserHasBadgeAsync(Player , BadgeId) then
return end
end
end)
maybe this works
Its a server script
It’s made for gamepasses though. I need it for the Developer products. But thanks anyways
Hi! So what you want is, that they get a badge when buying the Developer Product, but the badge is not used for anything like… detecting if they had bought the product before?
Hi! I want to make a “You Donated” badge, I haven’t published my game yet, so I don’t think detecting if they had bought the product before would be necessary. But it wouldn’t be bad
I’m only asking so I know your use-case. Is it only so they get a badge for it, nothing else. The badge wont be used for anything at all in the game?
Oh, yes. It’s only so they get the badge for it, nothing else
Check out this roblox tutorial on it… seems you must record the receipt of the dev product purchase and then u can call up that information in your script:
is it okay if i use this. it looks helpful.
Hello @george_xp
This script would fix you’re issue:
-- // Services
local MarketPlace = game:GetService("MarketplaceService")
local BadgeService = game:GetService("BadgeService")
-- // Var
local ProductID = 0
local BadgeID = 0
-- // Give the Prompt Product (This is just for prompt the ProductId you can remove it)
game.Players.PlayerAdded:Connect(function(plr)
task.wait(5)
MarketPlace:PromptProductPurchase(plr,ProductID)
end)
MarketPlace.PromptProductPurchaseFinished:Connect(function (Userid,Product_Id,Purchased)
if Product_Id == ProductID and Purchased then
if not BadgeService:UserHasBadgeAsync(Userid,BadgeID) then
BadgeService:AwardBadge(Userid,BadgeID)
end
end
end)
Yes it gives a badge, but whenever I join the game, Devproduct appears on the screen imideatly
Hello everyone, my friend gave me this working script, I will send it for people that have the same problem as me.
-- Marketplace Service --
local MarketplaceService = game:GetService("MarketplaceService")
-- Get the BadgeService --
local BadgeService = game:GetService("BadgeService")
local ContributorBadge = 0
-- Product Table --
local ProductTable = {
ProductId = 0
}
local function processReceipt(receiptInfo)
local Player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not Player then
print("Player cannot be located.")
-- Return to roblox saying that the player left or never completed the transcation --
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if Player then
print("Found player.")
-- Give the player goods depending on what they actually bought --
if receiptInfo.ProductId == ProductTable.ProductId then
if BadgeService:UserHasBadgeAsync(Player.UserId, ContributorBadge) then
-- do nothing
else
print(Player.Name.." donated 15 robux and received the Contributor badge at "..receiptInfo.ProductId)
BadgeService:AwardBadge(Player.UserId, ContributorBadge)
end
end
end
-- Kindly tell roblox they actually bought it
return Enum.ProductPurchaseDecision.PurchaseGranted
end
-- Set the callback
MarketplaceService.ProcessReceipt = processReceipt
Enjoy!
thank you so much i have been looking for something like this for a while.