says : Rank is not a valid member of Folder
**Line : 13**
23:14:56.361 - Stack Begin 23:14:56.361 - Script 'ServerScriptService.Leaderboard', Line 13 23:14:56.361 - Stack End
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PlayerStats")
game.Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
local Stats = Instance.new("Folder")
Stats.Name = "stats"
Stats.Parent = Player
local Currency = Instance.new("StringValue")
Currency.Name = "Rank"
Currency.Value = DataStore:GetAsync(Player.UserId).Rank or "0"
Currency.Parent = Stats
local Currency_ = Instance.new("StringValue")
Currency.Name = "Coin"
Currency.Value = DataStore:GetAsync(Player.UserId).Coin or "0"
Currency.Parent = Leaderstats
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, {
["Rank"] = Player.stats.Rank.Value;
["Coin"] = Player.leaderstats.Coin.Value;
})
end)
