Message when purchasing in chat

Hello DevForum users!

I have a problem, I want to make sure that when I buy a game pass or a developer’s product, a message is sent to all servers in the chat, but I can’t do it, can you help me?

Let’s say a user bought a gamepass, then the message “player1 bought gamepass1” is sent to the chat.

1 Like

Yes, you can do that with using MarketplaceService funtions.

if you have any codes, you wanna share with us?

1 Like

At the moment I do not have access to a PC.

No need to rush, you can send your code when you are back at PC

1 Like

I’ll try to find this script, but it would be better if someone could help make it better

1 Like

also you want all servers? in the chat?

Preferably yes, but you can start with one server

1 Like

okay so you do that with using these;

also use remote event and fire all clients for sending all messages to the chat

1 Like

–Look what’s wrong with this script

local function
donateButtonClicked(donateButton)

					local itemId = donateButton.Value.Value
					local itemPrice = donateButton.Price.Value

					MarketPlaceService:PromptPurchase(loser, itemId)

					MarketPlaceService.PromptPurchaseFinished:Connect(function(loser, itemId, was_purchased)

						if was_purchased then

							loser.leaderstats.Donated.Value += itemPrice
							local playerId = loser.UserId

							game.StarterGui:SetCore("ChatMakeSystemMessage", {
								Text = "[SYSTEM] "..loser.." donated "..itemPrice.." robux to "..winnerName;
								Font = Enum.Font.Cartoon;
								Color = Color3.new(0,255,0);
								FontSize = Enum.FontSize.Size96;
							})
						end

					end)
				end

This is not my script, but I tried to use it

1 Like