Need help with private system messages

I have this script

game.StarterGui.ResetPlayerGuiOnSpawn = false
old_fog = game.Lighting.FogStart
local MarketplaceService = game:GetService(“MarketplaceService”)

function getPlayerFromId(id)
for i,v in pairs(game.Players:GetChildren()) do
if v.userId == id then
return v
return nil

MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = getPlayerFromId(playerId)
local productName
if productId == 134468388 then

return Enum.ProductPurchaseDecision.PurchaseGranted

And want to make it so that after the purchase it will send a system message. But I want it to only be visible for the person who bought the item.

bc =“Dark stone grey”)
game.StarterGui:SetCore(“ChatMakeSystemMessage”, {
Text = “Private Text would be here”;
Font = Enum.Font.Cartoon;
Color = bc.Color;
FontSize = Enum.FontSize.Size96;

^it would be similar to that, but I don’t know what to add to make it private. (as In once the player completes the purchase it would show up in the chat

I’m guessing this is a Script right?

You can use a RemoteEvent to :FireClient the player and then in a LocalScript, inside StarterGui, :Connect upon .OnClientEvent and create a System Message. This will be only visible to the LocalPlayer.

FYI: There’s a built-in function for getting the player in the server with the corresponding id:

1 Like

So what chages would be made to the script?

Well for getting the player, you can use the function as I linked above:

local player = game:GetService("Players"):GetPlayerByUserId(playerId)

And then in the if statement (if productId == 134468388 then) you’ll need to fire client your RemoteEvent

local RemoteEvent = --// List it here
1 Like

Separate your work. Get all the Gui work off of the server. The server should only be responsible for processing the purchase and the client should be responsible for doing anything interface-wise.

For your code, four things: make sure to use GetService to fetch services as it is the canonical way to access services and it helps maintain consistency in your code. As mentioned above too, use functions supported in the engine to do things. GetPlayerByUserId already exists so use that instead of creating your own custom function. Third, old_fog - use a local variable. Don’t know why this exists though.

Now the fourth and most important, to it’s own paragraph: you must reject purchases that are unable to be processed. You have no handler for issues with purchases, such as if the player is not currently in the game, which can be fatal for players and yourself. Unhonoured purchases fall under scamming and will result in the loss of your account. Take percaution and read ProcessReceipt’s documentation.

When it comes to the client showing text, don’t use a remote (cc @return_end1). You’d be generating unnecessary network traffic here. Where possible, try not to use remotes. Here, you will want to use PromptProductPurchaseFinished to determine when the product purchase prompt is closed. Once a player buys your product, you can send the message over.

Applying all this together, you should have two scripts in general. I can give you the code but hopefully you weren’t expecting scripts to be given to you from the start. You never asked a question, just threw a script on your thread and stated what you want. Please confer with our category guidelines in the future when intending to post to this category. This category is not a venue for you to get code written for you, it is to help you help yourself. You need to put the effort into trying to accomplish things on your own by reading API and testing things out.

Server script to handle purchases, should be in ServerScriptService:

-- Run this from the command bar instead, or a different script
game:GetService("StarterGui").ResetPlayerGuiOnSpawn = false
-- camelCase for variables is my preference
local oldFog = game:GetService("Lighting").FogStart

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local productId = receiptInfo.ProductId
    local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)

    if not player then
        return Enum.ProductPurchaseDecision.NotProcessedYet

    if productId == 134468388 then
        ServerStorage.Admin:Clone().Parent = player.Backpack

    return Enum.ProductPurchaseDecision.PurchaseGranted

LocalScript that sends the personal message, should be in StarterPlayerScripts:

local StarterGui = game:GetService("StarterGui")
local MarketplaceService = game:GetService("MarketplaceService")
local LocalPlayer = game:GetService("Players").LocalPlayer

local MESSAGE_COLOR ="Dark stone grey").Color

-- I prefer this way of doing my functions nowadays
local function promptProductPurchaseFinished(userId, productId, isPurchased)
    -- Confirm all our parameters are correct just in case
    if LocalPlayer.UserId == userId and productId == 134468388 and isPurchased == true then
        StarterGui:SetCore("ChatMakeSystemMessage", {
            Text = "Welcome to the admin side!",
            Font = Enum.Font.Cartoon,
            FontSize = Enum.FontSize.Size96, -- Don't actually make it 96
            Color = MESSAGE_COLOR,


Just saying, I don’t recommend using SetCore’s ChatMakeSystemMessage function anymore. Considering the absolute extensiveness of the API and modularisation of the Lua Chat System, realistically you could keep this all server-sided. The Lua Chat System is also standard for working with chat-based necessities. SetCore is can also be unreliable for time and will throw errors if core options aren’t registered.

If you want to do this using the Lua Chat System, get rid of the LocalScript and refer to the Lua Chat System API. What you will need to do is get the speakers of the player and the server (one is created automatically, but you can create one yourself) and then have the server’s speaker send a message to the player’s speaker via the SendMessage method of the ChatSpeaker class.


Thank you so much, wasn’t expecting such a response. This has helped me a lot.
Take care (: