generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

i need help with in game purchases

Previous Thread :: Next Thread 
Pvcp is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image