I created a script that converts your statistics into money, but it doesn’t work and gives this error.
Script
local sellpad = script.Parent
local prices = {
['Rock'] = 1,
['Coal'] = 2,
['Iron'] = 4,
['Сopper'] = 6,
['Gold'] = 15,
['Platinum'] = 25,
['Sapphire'] = 45,
['Ruby'] = 65,
['Emerald'] = 130,
['Diamond'] = 250
}
local function sell(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
local amount = 0
for _, type in pairs(player.Stats:GetChildren()) do
amount = amount + (prices[type.Name] * type.Value)
type.Value = 0
end
player.leaderstats.Money.Value = player.leaderstats.Money.Value + amount
end
end
sellpad.Touched:Connect(sell)
I also tried adding the print command to find out where the error was and found out that the script does not see half of the statistics.
local amount = 0
for _, type in pairs(player.Stats:GetChildren()) do
print(type) <-
amount = amount + (prices[type.Name] * type.Value)
type.Value = 0
full stats here
Thank you.