Pvcp
|
  |
| Joined: 07 Mar 2014 |
| Total Posts: 14 |
|
|
| 30 Mar 2014 12:43 PM |
i used thisscript: -- setup local variables local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 19372077
-- 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. In this case we are healing the player. player.Character.Humanoid.Health = 100 -- more feedback for the player. game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased a healing potion." 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
i used it in the work space
then i used this script in the gui: --[[This script goes inside of a TextBox which should be inside of a ScreenGui]] productId = 19372077 -- Replace 123123123 with the id of your developer product.
local MarketplaceService = Game:GetService("MarketplaceService") function UsernameFromID(ID) if type(ID) ~= "number" then return end local sets = game:service("InsertService"):GetUserSets(ID) for k, v in next, sets do if v.Name == "My Models" then return v.CreatorName end end end function giveRewards(player) -- do stuff you want to do here, using the variable player for the player that clicked it. To access the character, do player.Character. return Enum.ProductPurcaseDecision.PurchaseGranted end MarketplaceService.ProcessReceipt = function(receiptInfo) giveRewards(UsernameFromID(receiptInfo.PlayerId)) end script.Parent.MouseButton1Down:connect(function() Game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent, productId) end)
but there is a problem i can buy things but i dont recive the money |
|
|
| Report Abuse |
|