Ep 51. Boost Stats

When implementing our boost system into our player stats calculation, I mistakenly used the GetActiveDuration method rather than the HasBoost method. This would likely prevent the player stats calculation from including the effect of their active boosts.

Solution

Inside ReplicatedStorage/Utils/Stats update any usage of the method GetActiveDuration with HasBoost.

Alternatively you should be able to replace the script’s contents with the script below:

ReplicatedStorage/Utils/Stats.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PetsConfig = require(ReplicatedStorage.Configs.Pets)
local AchievementsConfig = require(ReplicatedStorage.Configs.Achievements)
local ShopConfig = require(ReplicatedStorage.Configs.Shop)
local BoostsConfig = require(ReplicatedStorage.Configs.Boosts)

local Stats = {}

function Stats.ClickMultiplier(player: Player, playerData)
    local multiplier = 1
    local ownsGamepass = ShopConfig.DoesPlayerOwnGamepass("2x Clicks", playerData)
    if ownsGamepass then
        multiplier += 1
    end
    
    local hasBoost = BoostsConfig.HasBoost("2x Clicks", playerData)
    if hasBoost then
        multiplier += 1
    end
    local rebirths = playerData.Rebirths
    multiplier += rebirths
    local petMultiplier = PetsConfig.GetEquippedClicks(playerData)
    multiplier += petMultiplier
    local achievementMultipliers = AchievementsConfig.GetMultipliers("Clicks", playerData)
    multiplier += (achievementMultipliers / 100)
    return multiplier
end

function Stats.GemMultiplier(player: Player, playerData)
    local multiplier = 1
    local ownsGamepass = ShopConfig.DoesPlayerOwnGamepass("2x Rebirth Gems", playerData)
    if ownsGamepass then
        multiplier += 1
    end
    
    local hasBoost = BoostsConfig.HasBoost("2x Gems", playerData)
    if hasBoost then
        multiplier += 1
    end
    
    return multiplier
end

function Stats.LuckMultiplier(playerData)
    local multiplier = 1
    
    local ownsVIPGamepass = ShopConfig.DoesPlayerOwnGamepass("VIP", playerData)
    if ownsVIPGamepass then
        multiplier += 0.25
    end
    
    local ownsLuckyGamepass = ShopConfig.DoesPlayerOwnGamepass("Lucky", playerData)
    if ownsLuckyGamepass then
        multiplier += 0.10
    end
    local ownsSuperLuckyGamepass = ShopConfig.DoesPlayerOwnGamepass("Super Lucky", playerData)
    if ownsSuperLuckyGamepass then
        multiplier += 0.30
    end
    
    local hasBoost = BoostsConfig.HasBoost("2x Luck", playerData)
    if hasBoost then
        multiplier += 1
    end
    
    return multiplier    
end

return Stats
Contents