Hello. I'm trying to make a shortcut to making a leaderboard. So instead of making each value manually, i just create a table including the name, class type, and parent.
Everything works fine except that it doesn't create a value for "MilesDriven"
i'm trying to make a shortcut for making a leaderboard thing but for some reason, it works except for one value.
Are there limits to tables and how can I fix this problem?
local NewStats = {
Stats = {"Folder", "p"},
Level = {"IntValue", "Stats"},
Exp = {"IntValue", "Stats"},
Money = {"IntValue", "Stats"},
JobsCompleted = {"IntValue", "Stats"},
MilesDriven = {"IntValue", "Stats"},
VehicleCount = {"IntValue", "Stats"},
}
game.Players.PlayerAdded:Connect(function(p)
for i,v in pairs(NewStats) do
local NewValue = Instance.new(v[1])
NewValue.Name = i
if v[1] == "IntValue" then
NewValue.Value = 0
end
if v[2] == "p" then
NewValue.Parent = p
else
for a,b in pairs(p:GetDescendants()) do
if v[2] == b.Name then
NewValue.Parent = b
end
end
end
end
end)
