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