I tried making a level leaderstat, but it does not show when I play. Here Is the code.
game.Players.PlayerAdded:connect(function(player)
local DataStore = game:GetService("DataStoreService")
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
for i,v in pairs(script:GetChildren()) do
local d = DataStore:GetDataStore(v.Name)
local x = Instance.new("NumberValue",leader)
x.Name = v.Name
x.Value = d:GetAsync(player.UserId) or v.Value
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for i,v in pairs(script:GetChildren()) do
print("Getting")
local DataStore = game:GetService("DataStoreService")
local d = DataStore:GetDataStore(v.Name)
d:SetAsync(player.UserId, player.leaderstats[v.Name].Value)
print("Saved")
end
end)

9 comments
Last time you call money you use capitalised M
It still does not show it when I play test it
I edited it. It should work now just copy the scripts
If this answer helped please accept my answer
it still does not show it for some reason
Is it in the local script
if so then put it in the Server script
no, it still does not work. Hmmm is it because of the new place that shows the players name?
I think I know why it didnt work