Yea, let me type him a function for that.
Very very unreliable, and its gonna make the code messy, again please use ProcessReciept
Okay, I’ll read the documentation, thank you.
Okay, I did it like this:
local function donateRebirth()
print("1")
game:GetService("MarketplaceService"):PromptProductPurchase(player,devproductId)
game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(player, id, isPurchased)
print("2")
if (id == 1570916668) then
print(player,id,isPurchased)
end
end)
end
but as you can see the main print is not printed, so it doesn’t work, because even if I cancel the print will still be
So you’ll have to use ProcessReceipt
I’d recommend looking at this answer on it.
Okay, I wrote a script like this:
local function donateRebirth()
print("1")
productFunctions[1570916668] = function()
print("donated")
end
end
but when you click on the button, only this is displayed:
and the offer to buy does not appear at all
Can I have a code example please?
Of course give me a second or two,
Okay so in your local script your going to want to do this:
local player = game:GetService("Players").LocalPlayer
local ld = player:WaitForChild("leaderstats")
local damage = ld.Damage
local rebirth = ld.Rebirth
local main = script.Parent
local button = main.makeRebirth
local donateButton = main.DonateRebirth
local devproductId = 1570940043
local function donateRebirth()
game:GetService("MarketplaceService"):PromptProductPurchase(player,devproductId)
if game:GetService("MarketplaceService").ProcessReceipt({PlayerId = player.UserId,ProductId = devproductId}) then --- User Purchased It
-- Put code here
end
end
donateButton.MouseButton1Click:Connect(donateRebirth)
donateButton.TouchTap:Connect(donateRebirth)
Then put this in a ServerScript (aka a regular Script)
local players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local debounce = false
MarketplaceService.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1570940043 and debounce == false then
debounce = true
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end
Sorry it took so long. ( I had to use some other forums since I’ve not worked with ProcessReceipt before.)
Okay, I did as you said inserted a local script… created a global one in serverscriptService, and inserted there another script that you gave me… but. When I wrote for example print(“Something”)… then it didn’t print and it gives this error when I click on it:
local function donateRebirth()
game:GetService("MarketplaceService"):PromptProductPurchase(player,devproductId)
if game:GetService("MarketplaceService").ProcessReceipt({PlayerId = player.UserId,ProductId = devproductId}) then --- User Purchased It
print("Was donated")
end
end
this print is not displayed
Going to look at it one second
Can you send a screenshot of the area around line 37 in “rebirthMake”
Here try this
local player = game:GetService("Players").LocalPlayer
local ld = player:WaitForChild("leaderstats")
local damage = ld.Damage
local rebirth = ld.Rebirth
local main = script.Parent
local button = main.makeRebirth
local donateButton = main.DonateRebirth
local devproductId = 1570940043
local function donateRebirth()
game:GetService("MarketplaceService"):PromptProductPurchase(player,devproductId)
end
donateButton.MouseButton1Click:Connect(donateRebirth)
donateButton.TouchTap:Connect(donateRebirth)
Oh wait this is a local script
DOn’t use that one second
okey, I wait, what should I do?
Client Script:
local player = game:GetService("Players").LocalPlayer
local ld = player:WaitForChild("leaderstats")
local damage = ld.Damage
local rebirth = ld.Rebirth
local main = script.Parent
local button = main.makeRebirth
local donateButton = main.DonateRebirth
local devproductId = 1570940043
local function donateRebirth()
game:GetService("MarketplaceService"):PromptProductPurchase(player,devproductId)
end
donateButton.MouseButton1Click:Connect(donateRebirth)
donateButton.TouchTap:Connect(donateRebirth)
Server Script
local players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local debounce = false
local productFunctions = {}
productFunctions[1570940043] = function(_receipt, player)
-- Code here
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1570940043 and debounce == false then
debounce = true
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end
Okay, I clicked the button, the offer to buy came up… but it didn’t display what I wanted, which is what I wanted:
local players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local debounce = false
local productFunctions = {}
productFunctions[1570940043] = function(_receipt, player)
print("Donated") -- new code
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1570940043 and debounce == false then
debounce = true
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end