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
