Hi, does anyone know how to make a GUI that will pop up on everyone’s screen once a developer product is purchased?
Check out the article:
Developer Products – In‑Game Purchases (roblox.com)
You will want to create a purchase receipt to the product, in which you’ll fire a remote event to all clients. The clients will have to listen for this event and make the GUI pop up on their own screens.
Use Notification
system, there are existing tutorials on it.
If you want the msg to pop up for everyone, then fire all clients it, using a remote.
I believe that notification you showcased is using SetCore SendNotification method, which is a method that many people use and doesn’t require too much knowledge, you can implement this pretty simply whilst using the information above. I’ll give you a quick sample here.
Keep in mind this requires you to have a remote in ReplicatedStorage called Notify
.
– Client Script
local Players = game:GetService("Players")
local function NotifyofPurchase(player)
game.StarterGui:SetCore("SendNotification", {
Title = "Gamepass";
Text = player.." has purchase an extra life.";
Duration = 10;
Icon = Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420);
})
end
game.ReplicatedStorage.Notify.OnClientEvent:Connect(NotifyofPurchase)
– Server Script (this is literally copy and pasted from the wiki, it contains a lot of extra things you probably wont want but honestly it will work just fine. I’d highly recommend you take a read of it here )
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
productFunctions[1253115662] = function(receipt, player) -- replace the numbers here with ur dev product id.
game.ReplicatedStorage.Notify:FireAllClients(player)
return true
end
local function processReceipt(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
Thank you so much. It works perfectly!
Hi, do you have any idea what’s wrong with these scripts? I have followed your scripts and it worked fine for one, but I added another one dev product. But I’ve added another one. It doesn’t seem to be working. What is wrong with the scripts?
ReplicatedStorage
Hey, it looks like you’re using two separate receipt handlers, which won’t be needed. Try getting rid of the second server script you made and edit your original script to as follows:
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
productFunctions[1253115662] = function(receipt, player) -- the original product id.
game.ReplicatedStorage.Notify:FireAllClients(player)
return true
end
productFunctions[1253115662] = function(receipt, player) --pick topic id would be here
game.ReplicatedStorage.Notify2:FireAllClients(player)
return true
end
local function processReceipt(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
Also, for the second ID, are you sure you entered it correctly into the script? That may be another issue potentially. Let me know if it still errors and we can work out another solution together.
Thank you! This worked, however, I have an issue. It works perfectly on Roblox Studio. However, it doesn’t work in-game. Do you have any idea what happened?
That’s strange. Are you sure you published the place? Are you getting any errors when you open the developer console in the game?
No errors showed and I have published the place.
Is Studio Access to API option enabled in Game Settings?
Mhm, the Studio Access to API option is enabled.
What exactly happens in live studio testing and what happens in the actual game? Does anything happen at all on purchase?
Do you think this could be an issue?
I made a place with “Asset Manager” and then I used the product ID’s from the main game, not the game that I put the script in. (Idk if this sounds confusing)
Like gameshow groups.
Game hub (This is the place where the ID’s come from) → Trivia Showdown game (The place where I put the purchase scripts).
You’re going to want those dev products in the actual place. Try remaking them in the actual place, it should work fine at that point.
It works with the actual place, but, I have a quick question (probably weird q-). How do I config the dev products of the experiences under Asset Manager’s experiences (sorry if this sounds confusing). Like, whenever I click experiences settings, it only shows the main game’s dev products IDs + Settings.
where do I need to put these scripts?