local DataStoreService = game:GetService("DataStoreService") local Players = game:GetService("Players") local Settings = { FolderName = "leaderstats"; } setmetatable({}, Settings) local Alerts = function(AlertType, Message) AlertType = Message end local SaveData = function(Player: Player, self) local DataStore = DataStoreService:GetDataStore(Player.Name.."Stats") Player:WaitForChild(self.FolderName) wait(1) local StatStorage = Player:FindFirstChild(self.FolderName):GetChildren() for Index = 1, #StatStorage do StatStorage[Index].Value = DataStore:GetAsync(StatStorage[Index].Name) Alerts(print, "Stat Number "..Index.." Has Been Found") end end local LoadData = function(Player: Player, self) local DataStore = DataStoreService:GetDataStore(Player.Name.."Stats") local StatStorage = Player:FindFirstChild(self.FolderName):GetChildren() for Index = 1, #StatStorage do DataStore:SetAsync(StatStorage[Index].Name, StatStorage[Index].Value) Alerts(print, "Has Successfully Found Data Number "..Index) end Alerts(print, "Stats Has Successfully Saved") end Players.PlayerAdded:Connect(function(Player: Player) SaveData(Player, Settings) end) Players.PlayerRemoving:Connect(function(Player: Player) LoadData(Player, Settings) end)