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 MPS = game:GetService("MarketplaceService")
local devproductId = 1570940043
local function donateRebirth()
print("1")
game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(player, id, isPurchased)
print("2")
if (id == 1570916668) then
print(player,id,isPurchased)
end
end)
end
donateButton.MouseButton1Click:Connect(donateRebirth)
donateButton.TouchTap:Connect(donateRebirth)
So this script is a local script that lies in the gui, but the problem is that when you click on the button is written only 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
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