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

This gives the person too much?

Asked by 10 years ago

I use this script to calculate purchases, and for some reason, it never closes out the transaction??? If you come back it will give you lots of free points for no reason at all.

-- setup local variables
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local fifty = 19674692
local onehundred = 19714149
local onefifty = 19714150
local twofifty = 19714154
local fivehundred = 19714156

-- 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 == fifty then

player.leaderstats.DestructoCoin.Value = player.leaderstats.DestructoCoin.Value + 50
popup = game.ReplicatedStorage.PointsAlert:Clone()
popup.Frame.Award.Value = 50
popup.Frame.Positive.Value = true
popup.Frame.Position = UDim2.new(0.8, 0, 0.6, 0)
popup.Parent = player.PlayerGui
end
if receiptInfo.ProductId == onehundred then

player.leaderstats.DestructoCoin.Value = player.leaderstats.DestructoCoin.Value + 110
popup = game.ReplicatedStorage.PointsAlert:Clone()
popup.Frame.Award.Value = 110
popup.Frame.Positive.Value = true
popup.Frame.Position = UDim2.new(0.8, 0, 0.6, 0)
popup.Parent = player.PlayerGui
end
if receiptInfo.ProductId == onefifty then

player.leaderstats.DestructoCoin.Value = player.leaderstats.DestructoCoin.Value + 165
popup = game.ReplicatedStorage.PointsAlert:Clone()
popup.Frame.Award.Value = 165
popup.Frame.Positive.Value = true
popup.Frame.Position = UDim2.new(0.8, 0, 0.6, 0)
popup.Parent = player.PlayerGui
end
if receiptInfo.ProductId == twofifty then

player.leaderstats.DestructoCoin.Value = player.leaderstats.DestructoCoin.Value + 275
popup = game.ReplicatedStorage.PointsAlert:Clone()
popup.Frame.Award.Value = 275
popup.Frame.Positive.Value = true
popup.Frame.Position = UDim2.new(0.8, 0, 0.6, 0)
popup.Parent = player.PlayerGui
end
if receiptInfo.ProductId == fivehundred then

player.leaderstats.DestructoCoin.Value = player.leaderstats.DestructoCoin.Value + 600
popup = game.ReplicatedStorage.PointsAlert:Clone()
popup.Frame.Award.Value = 600
popup.Frame.Positive.Value = true
popup.Frame.Position = UDim2.new(0.8, 0, 0.6, 0)
popup.Parent = player.PlayerGui
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

Answer this question