So in my last topic: How can I fix this?, I fixed the market script and was able to buy packs/cash/crystals. BUT, a new bug sprouted and now it gives you stats from the last thing you bought (if you buy crystals then buy cash twice you’ll get crystals twice).
Here is my script:
--// 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
[966463278] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 10000
end
},
[966463330] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 26250
end
},
[966463421] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 82500
end
},
[966463466] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 172500
end
},
[966463511] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 600000
end
},
[966463536] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 1250000
end
},
[966463586] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 3240000
end
},
[966463613] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 6000000
end
},
--crystals tiers
[967342219] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 45
end
},
[967342248] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 118
end
},
[967342261] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 371
end
},
[967342277] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 743
end
},
[967342311] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 2700
end
},
[967342329] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 5625
end
},
[967342343] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 14580
end
},
[967342355] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 27000
end
},
--limited offers
[967561226] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 26250000
end
},
[967561248] = {
Callback = function(player)
local stats = player:WaitForChild("leaderstats").Crystals
stats.Value = stats.Value + 1181250
end
},
--packs
[970778723] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 5000
local stat2 = player:WaitForChild("leaderstats").Crystals
stat2.Value = stat2.Value + 150
end
},
[971060036] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 4000
local stat2 = player:WaitForChild("leaderstats").Crystals
stat2.Value = stat2.Value + 80
end
},
[971060069] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 100000
local stat2 = player:WaitForChild("leaderstats").Crystals
stat2.Value = stat2.Value + 180
end
},
[971060091] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 1500000
local stat2 = player:WaitForChild("leaderstats").Crystals
stat2.Value = stat2.Value + 350
end
},
[971110628] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 15000000
local stat2 = player:WaitForChild("leaderstats").Crystals
stat2.Value = stat2.Value + 1250
end
},
[970778707] = {
Callback = function(player)
local stats = moneyFolder:WaitForChild(player.Name)
stats.Value = stats.Value + 15000
local stat2 = player:WaitForChild("leaderstats").Crystals
stat2.Value = stat2.Value + 200
end
},
}
for key, tab in pairs(PurchaseTable) do
if PurchaseInfo.ProductId == key then
tab.Callback(plr)
break
end
end
end
Market.ProcessReceipt = CompletePurchase
Sorry for the very long script!