How do I make a pet multiplier for my game

So, first of all you would need a table with all the equiped pets.

After, when u get the PetMultiplier, you would create a variable CurrentValue = 1

You will loop thought every pet in the table and get the PetMultiplierStats

for i, Pet in pairs(PetTable) do
CurrentMultiplier *= Pet.Multiplier
end

at the end, you will have the PetMultiplier = CurrentMultiplier

This method can be used if u want to equip more pets or infinite.

I just did that with 4 pets and each pet had a multiplier of 1.20
at the end I got 2.0736 when it should be 1.80

Do you have any more Ideas? Or should I just make it add the multipliers together?

I guess you don’t want like that, you can go to the classic way:

Add all the multipliers and multiply it with the ClickAmount * GamepassAmount

The only thing would be that if u have 2 pets with 1x multiplier you would have a 2x multiplier or if u have 4 pets with 1.2x you would have a 4.8x multiplier

I don’t want to make it 4.8, but I guess I have to, because we can’t think of anything.

well thanks for your help anyway, have a good day

Actually there is a way but more complicated

local ClickAmount = 1
local MultiplierValue = 1

for _, Pet in pairs(Table) do 
MultiplierValue = MultiplierValue + Pet.Stat 

end
if MultiplierValue ~= 1 then

MultiplierValue = MultiplierValue - 1

end


If u have 1 pet with 1.3x multiplier, it would result in
Multiplier = 1 + 1.3 - 1 = 1.3

Result = 1 * 1.3 = 1.3

If u have 2 pets, one with 1.5x and one with 2x, you would have this:

Multiplier = 1 + 1.5 + 2 - 1 = 3.5x

if u have 3 pets with 1.2 would be
Multiplier = 1 + 1.2 + 1.2 + 1.2 - 1 = 3.6x

Hope this helps you :slight_smile:

2 Likes