Donation Button Help

Hello, i am creating a donation GUI and i am running into some confusion on how i can get it to work in my favor. This is my first time using MarketPlaceService and i was wondering if i was doing this right :sweat_smile:

Heres my current code

--Client 
local frame = script.Parent
local smallButton = frame["Small Donation"]
local mediumButton = frame["Medium Donation"]

local largeButton = frame["Large Donation"]
local event = game.ReplicatedStorage.Event
local CD = false

local MPS = game:GetService("MarketplaceService")
local IDs = {
	smallDonationID = 1279686382
}
local plr = game.Players.LocalPlayer


smallButton.Activated:Connect(function(i, c)
	if CD == false then
		CD = true
		MPS:PromptPurchase(plr, IDs.smallDonationID)
		task.wait(5)
		CD = false
	end
end)
--Server
local MPS = game:GetService("MarketplaceService")
local IDs = {
	smallDonationID = 1279686382
}

function processReciept(recieptInfo)
	local plr = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
	if not plr then
		-----------
		--player probably left the game, make sure they get prompted once they rejoin
		return Enum.ProductPurchaseDecision.NotProcessedYet
	else
		print(plr.Name)
	end
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

MPS.ProcessReceipt = processReciept

I followed the API doccumentation, and its not really working the way i intended it to work. (The output isnt printing)

I also have a few questions

  1. Is there a way i can use the same function to work with different dev products without having to write in different scripts?
  2. When i try out the dev product in game, it doesnt show the correct product (even tho i have the right ID), i assume its because ive only tested it in studio but i was wondering if this happened to other people as well.

My goal is to create a donation button, i might be overcomplicating things but im unsure. Help would greatly be appriciated, thank you for your time :slightly_smiling_face:

1 Like

You could try doing gamepasses

local mps = game:GetService("MarketplaceService")
local GamePassID = 0

game.Players.PlayerAdded:Connect(function(plr)
	if mps:UserOwnsGamePassAsync(plr.UserId, GamePassID) then
		game.ServerStorage["Product Name"]:Clone().Parent = plr:WaitForChild("Backpack")
		game.ServerStorage["Product Name"]:Clone().Parent = plr:WaitForChild("StarterGear")
	end
end)


game.ReplicatedStorage.Purchase.OnServerEvent:Connect(function(plr)
	game.ServerStorage["Product Name"]:Clone().Parent = plr:WaitForChild("Backpack")
	game.ServerStorage["Product Name"]:Clone().Parent = plr:WaitForChild("StarterGear")
end)

1 Like

For just donations try

local player = game.Players.LocalPlayer
local donateId = 0

script.Parent.MouseButton1Click:Connect(function()
	game.MarketplaceService:PromptProductPurchase(player, donateId)
end)
1 Like