I have made a function that loops through players’ pets, which should technically add up the total amount of money (multipliers) for all pets, then return it.
For some reason, it only returns the value from a single pet (which it isn’t supposed to), even though there are lots of pets in the inventory and it loops through all of them.
function DataService:CalculateBuff(player, class)
local MoneyBuff = 0
local Inventory = PlayerSessionData[player].Pets.Inventory
for _, GUIDs in pairs(Inventory) do -- loops through all pets (Ids)
for _, petType in pairs(GUIDs) do --gets the pet type and should add value.
MoneyBuff = PetModule[petType].Buffs.Money + PetModule[petType].Buffs.Money
end
end
if class == "Money" then
return MoneyBuff
end
end