Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Developer Product script not working?

Asked by 10 years ago

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

1 answer

Log in to vote
-1
Answered by 10 years ago

Did you create the button? You can go into ROBLOX studio create a sign with "TextButton" after that insert the button script into it

If that didn't work message me and I'll help you to the best of my ability.

0
I did create the button. I basically just copied the model and changed it to my liking. DrCylonide 158 — 10y
0
Send me a message on ROBLOX giving me the link to the model and I'll fix it KohlsCommands 0 — 10y
Ad

Answer this question