basically, ive made a donation system for my game, it works well, but i also want the game to send a message to the chat saying if someone had donated.
although, i have no idea how to do that, and i do not use the new chat for my game, and i do not want to change it, so is there a way to do this for legacy chat?
ive tried searching here for anything, but didnt get anything useful.
anything is appreciated
The legacy chat system uses “ChatMakeSystemMessage” to create a system message.
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
Text = "TextHere",
Color = Color3.fromRGB(255, 0, 0),
Font = Enum.Font.Michroma,
FontSize = Enum.FontSize.Size24
})
So create a RemoteEvent, and let a server script receive messages from a single server with Messaging Service, whilst broadcasting a message to all the clients via RemoteEvent with the server script:
local connection = MessagingService:SubscribeAsync("Donation", function(message)
game.ReplicatedStorage.Announce:FireAllClients(message.Data)
end)
-- Example Line for Global Donation
MessagingService:PublishAsync("Donation", "PLAYER has donated 99,999 Robux!")
And let the client catch that event, and display the message in their chat.
game.ReplicatedStorage.Announce.OnServerEvent:Connect(function(Message)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
Text = Message,
Color = Color3.fromRGB(100, 255, 100),
Font = Enum.Font.Michroma,
FontSize = Enum.FontSize.Size24
})
)
And there you have it. Global Donations.
The code hasn’t been tested, and is for educational purposes only.
Please do your own research on the functions and method used.
1 Like
thanks, but i have one question, how are you supposed to detect when the player actually purchases the dev product? since if i make it be on button click it would just appear even if the player didnt donate right?
There is the PromptProductPurchaseFinished
event of MarketplaceService
.
It provides 3 arguments: The UserID of the player who bought something, the ProductID AKA the ID of the dev product, and finally isPurchased for checking if the player actually bought the dev product or not.
So detecting a bought dev product works like so:
game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(userId: number, productId: number, isPurchased: boolean)
if not isPurchased then -- If not purchased, then return as we don't need a rejected request.
return
end
end)
1 Like
And just so you know—Posts that have answered your question should be marked as an answer.
one more thing, where exactly am i supposed to put the scripts? im a bit confused at the first 3.