I have a purchase error saying ReceiptId already being processed. for no reason
self.RunnedModules = {}
self.Modules = {}
self.RunnedValues = {}
for i,Module in pairs(self.ServerBaseModules:GetChildren()) do
if Module:IsA("ModuleScript") and Module.Name ~= "initilizeTable" then
self.Modules[Module.Name] = require(Module)
self.RunnedModules[Module.Name] = self.Modules[Module.Name]:RunModule()
end
end
self.InitlizePurcahseModule = function(Action,ModuleIndex,Player)
for RunnedModuleIndex,RunnedModule in pairs(self.RunnedModules) do
if RunnedModuleIndex == ModuleIndex then
if Action == "Activate" then
if self.ServerBaseModules.ActivationValues[RunnedModuleIndex].Value ~= true then
RunnedModule.Activate(Player)
end
elseif Action == "Extend" then
if self.ServerBaseModules.ActivationValues[RunnedModuleIndex].Value == false then
RunnedModule.Extend(Player)
end
end
end
end
end
self.DecideAction = function(ActionName)
if self.ServerBaseModules.ActivationValues[ActionName].Value == false then
return "Activate"
elseif self.ServerBaseModules.ActivationValues[ActionName].Value == true then
return "Extend"
end
end
self.Purchased = function(Receipt)
local status = Enum.ProductPurchaseDecision.NotProcessedYet
local PurGr = Enum.ProductPurchaseDecision.PurchaseGranted
local Plr = game.Players:GetPlayerByUserId(Receipt.PlayerId)
local ReceiptId = Receipt.ProductId
pcall(function()
if not Plr then
return status
end
for index,Module in pairs(self.Modules) do
if Module.ProductId == ReceiptId then
self.InitlizePurcahseModule(self.DecideAction(index),index,Plr)
return PurGr
end
end
end)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
return self
end
return PurchaseModule.new()
im using oop for purchase