Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

attempt to perform arithmetic (mul) on nil and number. Why is this happening? Can someone fix?

Asked by 3 years ago

I am making this game where you collect crystals as a intvalue, and you can sell them. I keep getting this error and i don't know why. I have defined prices btw.

local function sellGems(otherPart)
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    if player then 
        local amount = 0
        for _, type in pairs(player.Inventory:GetChildren()) do
            amount = amount + (prices[type.Name] * type.Value)
            type.Value = 0
        end
        player.leaderstats.Money.Value = player.leaderstats.Money.Value + amount
    end
end

Answer this question