Why does this part of my script not work

Its supposed to display a system message in chat but it doesn’t appear for some reason, any idea why?

					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

Are you using the older chat functions which have been superceded? You are using invalid references to the GUI using game.StarterGui. Everything in ``game.StarterGuigets replicated to the player client on join and thus becomes a local reference to the player, iegame.Players.LocalPlayer.PlayerGui```.

I send system messages in chat using the following

game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("Your message", "RBXSystem")
1 Like

You shouldn’t be handling purchases like this, and you’re also not respecting the client-server boundary which is why it doesn’t work.

Resources to use: Developer Products | Documentation - Roblox Creator Hub, Remote Events and Callbacks | Documentation - Roblox Creator Hub

1 Like

the text method you are using is old, and loser is a player instance so you should be addresing loser.Name in your text.

1 Like

I don’t understand, how should I be handling purchases, I had the script on the client side but people said it was vulnerable to hackers so to keep it on the client side.

Ah yes, thanks I have corrected it now

if thats so then you should mark a answer as a solution

Well its still not working, I was just saying thanks for correcting that issue

whats still not working? what other isssues are there?

One of the links I sent was written by Roblox on how to handle purchases properly.

Yeah, you should have a script on the server side.