The devproduct handler only works in the studio and even prints it all out perfectly, but when I try it in a game server it wouldn’t even trigger the first function…
--//Receipts Handler\\--
MarketplaceService.ProcessReceipt = function(recieptInfo)
print(1)
local Player = Players:GetPlayerByUserId(recieptInfo.PlayerId)
if not Player then
print(2)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if recieptInfo.ProductId == devProduct then
print(3)
for _, plr in Players:GetPlayers() do
print(4)
if (plr.UserId ~= Player.UserId) then
print(5)
local Character = plr.Character
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
print(6)
Humanoid.Health = 0
end
end
end
KillAllValidation:FireAllClients(Player)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
So I’m saying the script works in studio when I run it, it checks out it does anything as written but when, I publish it, Save it whatnot… and yet when I try it in game through the Roblox launcher not even one print works…
if you set MarketplaceService.ProcessReceipt in any other scripts in your game then the script that you are currently editing may not register ProcessReceipt, so check the scripts in your game (particularly scripts from any free models you have inserted, if any) and add any instances of ProcessReceipt to your current script.
for example,
in the first screenshot you sent, it looks like you have a clothing picker.
if that clothing picker allows you to purchase the clothes, and uses MarketplaceService.ProcessReceipt, then you might not be able to use MarketplaceService.ProcessReceipt in your script.
.
if you would like me to explain anything in further detail, let me know!
I saw in your output there was an error. Is that error related?
Maybe add some print statements to make sure the Humanoid is being found?
Also, I’d recommend using the structure in the documentation for receipt processing, it has more security.
local players = game:GetService("Players")
local mps = game:GetService("MarketplaceService")
local productFunctions = {}
productFunctions[123123] = function(info, player) --the numbers is your product ID
player.leaderstats.Money.Value += 300 --as an example
return true
end
local function processReceipt(info)
local player = players:GetPlayerByUserId(info.PlayerId)
local handler = productFunctions[info.ProductId]
local success, result = pcall(handler, info, player)
if success then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
mps.ProcessReceipt = processReceipt
It’s not my game but a commission I do, it turns out he had a donation board that process receipts in a module of course I’ve first checked if there’s anything that uses processreceipt function but now when I looked deeper I tried to disable the donations board and it works, thanks.
Obviously I tested it along with testers dozens of times what type of question is that when the if statement of the player.id ~= receiptinfo.playerid can be simply removed or modified and I can test it on my self, not to mention I didn’t do it and I had testers…