--// Services
local Market = game:getService("MarketplaceService")
local moneyFolder = game.ServerStorage:WaitForChild("PlayerMoney")
--// Functions
local function CompletePurchase(PurchaseInfo)
local plr = game:GetService("Players"):GetPlayerByUserId(PurchaseInfo.PlayerId)
local PurchaseTable = {
--Cash tiers
CashTier1 = {ID = 966463278, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 10000},
CashTier2 = {ID = 966463330, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 26250},
CashTier3 = {ID = 966463421, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 82500},
CashTier4 = {ID = 966463466, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 172500},
CashTier5 = {ID = 966463511, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 600000},
CashTier6 = {ID = 966463536, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 1250000},
CashTier7 = {ID = 966463586, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 3240000},
CashTier8 = {ID = 966463613, Currency = moneyFolder:WaitForChild(plr.Name), Reward = 6000000},
--Crystals tiers
CrystalsTier1 = {ID = 967342219, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 45},
CrystalsTier2 = {ID = 967342248, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 118},
CrystalsTier3 = {ID = 967342261, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 371},
CrystalsTier4 = {ID = 967342277, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 743},
CrystalsTier5 = {ID = 967342311, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 2700},
CrystalsTier6 = {ID = 967342329, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 5625},
CrystalsTier7 = {ID = 967342343, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 14580},
CrystalsTier8 = {ID = 967342355, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 27000},
--Limited offers
CashLimitedOffer = {ID = 967561226, Currency = plr:WaitForChild("leaderstats").Cash, Reward = 26250000},
CrystalsLimitedOffer = {ID = 967561248, Currency = plr:WaitForChild("leaderstats").Crystals, Reward = 1181250},
--Packs and bundles
StarterPack = {ID = 970778723, Currency1 = moneyFolder:WaitForChild(plr.Name), Currency2 = plr:WaitForChild("leaderstats").Crystals, Reward1 = 5000, Reward2 = 150},
NoobPack = {ID = 971060036, Currency1 = moneyFolder:WaitForChild(plr.Name), Currency2 = plr:WaitForChild("leaderstats").Crystals, Reward1 = 4000, Reward2 = 80},
ProPack = {ID = 971060069, Currency1 = moneyFolder:WaitForChild(plr.Name), Currency2 = plr:WaitForChild("leaderstats").Crystals, Reward1 = 100000, Reward2 = 180},
GodPack = {ID = 971060091, Currency1 = moneyFolder:WaitForChild(plr.Name), Currency2 = plr:WaitForChild("leaderstats").Crystals, Reward1 = 1500000, Reward2 = 350},
HackerPack = {ID = 971110628, Currency1 = moneyFolder:WaitForChild(plr.Name), Currency2 = plr:WaitForChild("leaderstats").Crystals, Reward1 = 15000000, Reward2 = 1250},
BetaBundle = {ID = 970778707, Currency1 = moneyFolder:WaitForChild(plr.Name), Currency2 = plr:WaitForChild("leaderstats").Crystals, Reward1 = 15000, Reward2 = 200},
--[[Boosts
CashChoice1 = {ID = 971407264},
CrystalsChoice1 = {ID = 971407332},
CocoaChoice1 = {ID = 971407380},
CashChoice2 = {ID = 971407277},
CrystalsChoice2 = {ID = 971407337},
CocoaChoice2 = {ID = 971407386},
CashChoice3 = {ID = 971407280},
CrystalsChoice3 = {ID = 971407340},
CocoaChoice3 = {ID = 971407393},]]
}
for i,v in pairs(PurchaseTable) do
if v.ID <= 967561248 then
if PurchaseInfo.ProductId == v.ID then
v.Currency.Value = v.Currency.Value + v.Reward
print("+SUCCESS+")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
elseif v.ID >= 970778723 and v.ID <= 970778707 then
if PurchaseInfo.ProductId == v.ID then
v.Currency1.Value = v.Currency1.Value + v.Reward1
v.Currency2.Value = v.Currency2.Value + v.Reward2
print("+SUCCESS+")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
--[[elseif v.ID >= 971407264 then
if PurchaseInfo.ProductId == v.ID then
local RE = game.ReplicatedStorage.RemoteEvents.Boosts:WaitForChild(i)
if RE ~= nil then
print("Yay")
RE:FireClient(plr)
else
error("ERROR ERROR ERROR")
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end ]]
end
end
end
local function gamepassCompletePurchase(plr)
print(tostring(plr) .. " bought a gamepass")
game.ReplicatedStorage.RemoteEvents.GamepassBought:FireClient(plr)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Market.ProcessReceipt = CompletePurchase
--//GAMEPASS HANDLING//--
Market.PromptGamePassPurchaseFinished:Connect(gamepassCompletePurchase)
This is my market script and only this part doesn’t work:
elseif v.ID >= 970778723 and v.ID <= 970778707 then
if PurchaseInfo.ProductId == v.ID then
v.Currency1.Value = v.Currency1.Value + v.Reward1
v.Currency2.Value = v.Currency2.Value + v.Reward2
print("+SUCCESS+")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
The output shows nothing if I buy a pack (it doesn’t work), but the output does show something if I buy crystals/cash and it works.
Apparently the ProductId is not v.ID so…
How should I do this then?