Having issues with making system messages

i’m currently working on a system that checks for when a player purchases an item, and when they do it sends a system message on what item they purchased.

as of right now i’m trying to make it as simple as possible with just one server script and very easy code.

my issue is that i’ve tried literally every way to create system messages and now i’m on my last resort trying to use the “Chat” service like this:

game:GetService("Chat"):Chat(game.Workspace, SystemMessage, Enum.ChatColor.Red)

i’ve used local scripts already to try and just make the messages appear for one player with the

StarterGui:SetCore("ChatMakeSystemMessage", {
RANDOM_PARAMETER = nil
})

and to absolutely no avail.

here is the full script:

-- Server script for the proximity prompt purchase interaction.

local CatalogItemID = 1609390589
local ProximityPrompt = script.Parent

-- Function to handle the player interaction.
local function PromptTriggered(Player)
	if Player then
		-- Prompt player to purchase the catalog item.
		game:GetService("MarketplaceService"):PromptProductPurchase(Player, CatalogItemID)
	end
end

-- Function to handle the result of the product prompt.
local function ProductPurchaseFinished(Player, ItemID, Purchased)
	local Plr = game:GetService("Players"):GetPlayerByUserId(Player)
	
	if ItemID == CatalogItemID then
		if Purchased then
			-- Create a system message in the chat when the item is successfully purchased.
			local SystemMessage = "[SYSTEM] " .. Plr.Name .. " successfully purchased the item (ID: " .. ItemID .. ")!"
			game:GetService("Chat"):Chat(game.Workspace, SystemMessage, Enum.ChatColor.Blue)
		else
			-- Optionally notify when the purchase is canceled.
			local SystemMessage = "[SYSTEM] " .. Plr.Name .. " did not purchase the item (ID: " .. ItemID .. ")."
			game:GetService("Chat"):Chat(game.Workspace, SystemMessage, Enum.ChatColor.Red)
		end
	end
end

-- Connect the function to the proximity prompt's triggered event.
ProximityPrompt.Triggered:Connect(function(Player)
	PromptTriggered(Player)
end)

-- Listen for the PromptProductPurchaseFinished event to check if the item was purchased.
game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(ProductPurchaseFinished)

any help would be much appreciated

If you are using TextChatService; you have to use these new methods:

ChatService:Chat()TextChatService:DisplayBubble()

StarterGui:SetCore('ChatMakeSystemMessage')TextChatService.TextChannel:DisplaySystemMessage()

example:

local TextChatService = game:GetService("TextChatService");
local TextChannel = TextChatService.TextChannel;
local SystemMessage = `[SYSTEM] {Plr.Name} successfully purchased the item (ID: {ItemID})!`;

TextChannel:DisplaySystemMessage(SystemMessage); 
TextChatService:DisplayBubble(game.Workspace, SystemMessage);

To add on to this, if you aren’t using TextChatService, you should migrate to it and use the answer above.

If you don’t know which one you’re using, this is TextChatService, the one you should migrate to:


Image Source: Customizing Text Chat | Documentation - Roblox Creator Hub

1 Like