Hello! I am currently adding up a players networth, then printing it. (Note: I will do something with networth later)
However, it prints
LocalWE Has a networth of $0
Even though I have most of the characters in the game.
local serverStor = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(plr)
local val = 0
for i, v in pairs(plr:WaitForChild("Characters"):GetChildren()) do
local module = require(serverStor.Characters[v.Name])
val += module.Cost
end
print(plr.Name.." Has a networth of $" ..val)
end)
Recently tried ipairs, but it does the same thing. I thought my requiring the module was wrong, but when I added other bodies and kart parts, it still says 0.
And the other kart parts don’t use a Module. They are BaseValue based.
So that leaves it off that my for loop is somehow wrong.
I printed val by itself, and it said 0, but nothing printed when I tried printing v and module.Cost
local serverStor = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(plr)
local val = 0
for i, v in pairs(plr:WaitForChild("Characters"):GetChildren()) do
local module = require(serverStor.Characters[v.Name])
print(v)
print(module.Cost)
val += module.Cost
end
print(plr.Name.." Has a networth of $" ..val)
print(val)
end)