I have encountered an issue when creating a script designed to prompt a purchase and then, when the DevProduct is bought, kill all other players. I am in the early stages of the script, so I haven’t scripted the actual killing of the players yet. I am merely trying to print something to the output when a DevProduct is purchased. There is no error in my output and nothing is printed.
My Code:
LocalScript inside of a ScreenGui:
local ProductId = 1707130936
local Player = game.Players.LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")
script.Parent.KillAllButton.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(Player, ProductId)
end)
Script inside of ServerScriptService:
local MPS = game:GetService("MarketplaceService")
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1707130936 then
print("it works")
end
end
Send the Information with a remote event and call the PromptProductPurchase on the server
local ProductId = 1707130936
local RemoteEvent = --create or path to RemoteEvent
local Player = game.Players.LocalPlayer
script.Parent.KillAllButton.MouseButton1Click:Connect(function()
RemoteEvent:FireServer(ProductId)
end)
local MPS = game:GetService("MarketplaceService")
local RemoteEvent = --path to RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(Player, ProductId)
MPS:PromptProductPurchase(Player, ProductId)
end)
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1707130936 then
print("it works")
end
end
Try putting in prints() around and see what triggers and what doesnt. For instance see if the click event is actually triggering
Side note that is unrelated-
Instead of using .MouseButton1Click use .Activated, MouseButton1Click well only works with a mouse so its a good practice to use .Activated that way it works for everyone (Well Idk if .Activated works with console or VR but for the most part its better)
I see no change at all in the outcome; nothing is printed and there are no errors. The RemoteEvent is definitely fired, though, as it does prompt the purchase.
Tried it, here are the results. Which ones printed are specified using comments.
local MPS = game:GetService("MarketplaceService")
local RemoteEvent = game.ReplicatedStorage.KillAll
RemoteEvent.OnServerEvent:Connect(function(Player, ProductId)
MPS:PromptProductPurchase(Player, ProductId)
print("purchase prompted") --printed
end)
MPS.ProcessReceipt = function(receiptInfo)
print("receipt processed") --didn't print
if receiptInfo.ProductId == 1707130936 then
print("it works") --didn't print
end
end
Well here is the document on Dev products and over all handling them.
Maybe check out how they handle them cause you might have done something wrong when handling the receipt. Thats all I can say for now.
I just noticed another thing, you have to return the productdecision as granted
local MPS = game:GetService("MarketplaceService")
local function processReceipt(receiptInfo)
if receiptInfo.ProductId == 1707130936 then
print("it works!")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
MPS.ProcessReceipt = processReceipt
No difference in the outcome.
30 ahsgegdge