How do i add multipliers to my pets

Hello, can someone tell me how i can add multipliers to my pets like a coin boost. There are no video’s on YT and i’ve been trying to do it for about a month now can someone help me?

1 Like

I would probably have a IntValue assigned to each pet, its value would be their current multiplier (if above 0) * chosen_multiplier.

When awarding ex. coins, you can check the pet’s IntValue.

I would have modules for all the pets with their boosts and stuff like that then loop through all the pets that the player has equipped and find the module(s) that are applicable and handle the boosts from there

I would put a NumberValue inside the player when they load in, and when they equip the pets it changes the NubmerValue’s value to the pet’s booster (or adds it to the NumberValue if its possible to have more than 1 pet equipped in your game)

Assuming you want a combined modifier for all pets

Step 1: You want to have some sort of way to configure and retrieve all information for a pet, common ways people do this is through a module of all pet information or attributes/value objects inside the pet model

Step 2: You need to store the combined multiplier somewhere so it can be accessed by other scripts, since the combined multiplier won’t be saved I recommend just making it an attribute inside of the player

Step 3: Add/Substract from the multiplier value whenever a pet is added/removed

example

-- on pet added
local petMultiplier = pet:GetAttribute("Multiplier")
local currentPlayerMultiplier = player:GetAttribute("Multiplier")
player:SetAttribute("Multiplier",  currentPlayerMultiplier + petMultiplier)

-- on pet removed
local petMultiplier = pet:GetAttribute("Multiplier")
local currentPlayerMultiplier = player:GetAttribute("Multiplier")
player:SetAttribute("Multiplier",  currentPlayerMultiplier - petMultiplier)

-- accessing player multiplier
player:GetAttribute("Multiplier")
4 Likes