Donations in-game not working

Hello, I’m PLX, I was updating my Roblox game but I ran into a problem, the donation messages that go on the chat are not working in-game, but only in the studio, so can someone explain what’s wrong?

Here are my scripts:

Server

game.MarketplaceService.ProcessReceipt = function(PI)
	local buyer = PI.PlayerId
	local Username = game.Players:GetPlayerByUserId(buyer)
	local PlrFormat = Username.Name.." ("..Username.DisplayName..")"
	if PI.ProductId == 1779402676 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"5")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381164 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"10")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381162 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"25")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381160 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"50")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381158 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"100")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381161 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"500")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381159 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"1000")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif PI.ProductId == 1523381157 then
		game.ReplicatedStorage.DonationServerMessage:FireAllClients(PlrFormat,"1000")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Client

game.ReplicatedStorage.DonationServerMessage.OnClientEvent:Connect(function(plr,arg)
	if not arg then return end
	if arg == "5" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 5 robux!</font>")
	elseif arg == "10" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 10 robux!</font>")
	elseif arg == "25" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 25 robux!!</font>")
	elseif arg == "50" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 50 robux! wow!</font>")
	elseif arg == "100" then	
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 100 robux!! Nice!</font>")
	elseif arg == "500" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 500 robux!! WOW!</font>")
	elseif arg == "1000" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>has donated \u{E002} 1,000 robux!! WOWWW!</font>")
	elseif arg == "10000" then
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[SERVER]: "..plr.." <font color='rgb(0,255,0)'>HAS DONATED \u{E002} 10,000 ROBUX!?!?! YOOOO!!</font>")
	end
end)

When you test it in-game, if you check the console does it print out any errors?

No, it doesn’t, if it did, I’d probably wouldn’t post this forum…

Well I tested your script in-game and it worked!

Maybe it’s the way you prompt the productid (yet again it works fine on studio)

hello!

the issue is likely that you are using ProcessReceipt in multiple scripts.

MarketplaceService.ProcessReceipt can only register once, so registering it again won’t do anything.

usually free models (such as donation stands, clothes buyers, etc.) use ProcessReceipt, which as mentioned previously could stop your code from registering.

to fix it, simply check if any free models/scripts in your game that require purchasing of products dont use ProcessReceipt, and if they do, move that code over to your code.

2 Likes

Thank you for helping me! It worked!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.