So I have this script in StarterPack to reward Money when someone buys a Dev Product:
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
CASHID = 19382769 -- Put the Developer Product ID here
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 == CASHID then
lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
cs = lds:FindFirstChild("Money") --Change to your leaderstat
if cs ~= nil then
cs.Value = cs.Value + 10 --Change to the amount you want this to add
end
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Then I have this script to reward Speed, Health, and gear when someone buys a Dev product:
local MarketplaceService = game:GetService("MarketplaceService")
local AddHealthID = 21831070 --ENTER
local AddSpeedID = 21831048 --PASS
local AddGearID = 21831095 --IDS
local AddGear2ID = 21831110 --IDS
local AddGear3ID = 21831126 --HERE
local AddGear4ID = 21831118 --IDS
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
if PurchaseHistory:GetAsync(playerProductKey) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
for i, player in ipairs(game.Players:GetPlayers()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == AddHealthID then
player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth + 50 --Adds 50 to their current health
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
end
if receiptInfo.ProductId == AddSpeedID then
player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 15 -- Adds 5 to their current Walkspeed
end
if receiptInfo.ProductId == AddGearID then
game.ReplicatedStorage.DualVenomshanks:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
end
if receiptInfo.ProductId == AddGear2ID then
game.ReplicatedStorage.GravityCoil:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
end
if receiptInfo.ProductId == AddGear3ID then
game.ReplicatedStorage.Jetpack:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
end
if receiptInfo.ProductId == AddGear4ID then
game.ReplicatedStorage.DualDarkhearts:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you
end
end
end
PurchaseHistory:SetAsync(playerProductKey, true)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
The first script that I showed and put in StarterPack works even the script above works also. But when I try to use them together the top script causes the second script to not works and also it does not work either. This is kinda bad since I am making a tycoon but I was wondering if anyone could help me make these two scripts compatible

2 comments
I thought that might be it do you know how I can fix that? maybe add it to the other script?
A modular system of handling items? using module scripts to handle specific items, all controlled through a server script?