When someone purchases for instance CASHID1 = 25264200 they're supposed to get 25 Gems, elseif the respective gems amount. This script was working when I only had CASHID1 but since I added 6 other variables it didn't work. (The gems are located in a model named "ds" in the player)
This script is in the serverscriptservice, but in the Gui I have the script that makes the purchase.
local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") CASHID1 = 25264200 CASHID2 = 25264211 CASHID3 = 25264216 CASHID4 = 25264234 CASHID5 = 25264242 CASHID6 = 25282009 MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId local numberBought = ds:IncrementAsync(playerProductKey, 1) for i,v in pairs (game.Players:GetChildren()) do if v.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == CASHID1 then lds = v:FindFirstChild("ds") if lds ~= nil then cs = lds:FindFirstChild("Gems") if cs ~= nil then cs.Value = cs.Value + 25 elseif receiptInfo.ProductId == CASHID2 then lds = v:FindFirstChild("ds") if lds ~= nil then cs = lds:FindFirstChild("Gems") if cs ~= nil then cs.Value = cs.Value + 50 elseif receiptInfo.ProductId == CASHID3 then lds = v:FindFirstChild("ds") if lds ~= nil then cs = lds:FindFirstChild("Gems") if cs ~= nil then cs.Value = cs.Value + 100 elseif receiptInfo.ProductId == CASHID4 then lds = v:FindFirstChild("ds") if lds ~= nil then cs = lds:FindFirstChild("Gems") if cs ~= nil then cs.Value = cs.Value + 250 elseif receiptInfo.ProductId == CASHID5 then lds = v:FindFirstChild("ds") if lds ~= nil then cs = lds:FindFirstChild("Gems") if cs ~= nil then cs.Value = cs.Value + 500 elseif receiptInfo.ProductId == CASHID6 then lds = v:FindFirstChild("ds") if lds ~= nil then cs = lds:FindFirstChild("Gems") if cs ~= nil then cs.Value = cs.Value + 1250 end end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end