It is supposed to work like if you press a button and pay the robux you get the currency, in this case "Bits". For some reason only the first one works "250 Bits". The buttons work but when you have pressed the buy button you get no bits. I can not even see that it printed in the output. Only the "Two_Fifty" one, that's the only that works. Why?
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local TouchBuy = game.Workspace.Lobby.Interactions.PickGame
local PreviousPurchases = DataStoreService:GetDataStore("PreviousPurchases")
local gamefolder = game.ReplicatedStorage.Game
local runningFunction = gamefolder.RunningFunction
local Two_Fifty = 1147088183 -- 250
local Eight_Fifty = 1147088184 -- 850
local One_Five_Hundred = 1147088185 -- 1,500
local Two_Five_Hundred = 1147088188 -- 2,500
local Eight_Five_Hundred = 1150501490 -- 8,500
local Fifteen_Tousand = 1150501488 -- 15,000
local Twenty_Five_Tousand = 1150501489 -- 25,000
local Eighty_Tousand = 1150501491 -- 80,000
local One_Fifty_Tousand = 1150501492 -- 150,000
MarketplaceService.ProcessReceipt = function(receipt)
local ID = receipt.PlayerId.."-"..receipt.PurchaseId
local success = nil
pcall(function()
success = PreviousPurchases:GetAsync(ID)
end)
if success then
--Purchase has already been done
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(receipt.PlayerId)
if not player then
--Left or disconnected
return Enum.ProductPurchaseDecision.NotProcessedYet
else
if receipt.ProductId == Two_Fifty then
print(player.Name.." bought 250 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +250
if receipt.ProductId == Eight_Fifty then
print(player.Name.." bought 850 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +850
end
if receipt.ProductId == One_Five_Hundred then
print(player.Name.." bought 1,500 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +1500
end
if receipt.ProductId == Two_Five_Hundred then
print(player.Name.." bought 2,500 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +2500
end
if receipt.ProductId == Eight_Five_Hundred then
print(player.Name.." bought 8,500 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +8500
end
if receipt.ProductId == Fifteen_Tousand then
print(player.Name.." bought 15,000 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +15000
end
if receipt.ProductId == Twenty_Five_Tousand then
print(player.Name.." bought 25,000 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +25000
end
if receipt.ProductId == Eighty_Tousand then
print(player.Name.." bought 80,000 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +80000
end
if receipt.ProductId == One_Fifty_Tousand then
print(player.Name.." bought 150,000 Bits!")
local ls = player:FindFirstChild("leaderstats")
ls.Bits.Value = ls.Bits.Value +150000
end
end
pcall(function()
PreviousPurchases:SetAsync(ID,true)
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Thanks for the help, if you need more information, just ask :) , Xsodar

3 comments
On line 44 there should be an end to close the first if (for 250 bits).
This was the problem, I think, it works at the moment at least. Thanks for pointing that out :)
I urge you to accept my answer.