I took this script from the ROBLOX wiki, and changed it to my needs (Product ID and such) but I will not work. I realize that this script is not made by me, but I would like this to work. What is wrong?
Here is the LOCAL SCRIPT in STARTER PACK:
--LocalScript in StarterPack
-- setup local variables
local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local productId = 21457157
-- when player clicks on buy brick prompt him/her to buy a product
buyButton.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
And here is the script in the buybutton thing:
--Script in BuyButton part
-- setup local variables
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 21457157
-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo)
-- find the player based on the PlayerId in receiptInfo
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
-- check which product was purchased
if receiptInfo.ProductId == productId then
-- handle purchase
player.leaderstats["Maple Leaves"].Value = player.leaderstats["Maple Leaves"].Value + 1000
end
end
end
-- record the transaction in a Data Store
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
ds:IncrementAsync(playerProductKey, 1)
-- tell ROBLOX that we have successfully handled the transaction
return Enum.ProductPurchaseDecision.PurchaseGranted
end

2 comments
I did create the button. I basically just copied the model and changed it to my liking.
Send me a message on ROBLOX giving me the link to the model and I'll fix it