slight problem here, trying to make deaths save but they don't, the leaderboard stats do work but deaths just don't save
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("BrickCountSaveSystem") local ds2 = datastore:GetDataStore("DeathSaveSystem") game.Players.PlayerAdded:connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local BrickCount = Instance.new("IntValue", folder) BrickCount.Name = "Bricks" local deathcount = Instance.new("IntValue", folder) deathcount.Name = "Deaths" BrickCount.Value = ds1:GetAsync(plr.UserId) or 0 ds1:SetAsync(plr.UserId, BrickCount.Value) BrickCount.Changed:connect(function() ds1:SetAsync(plr.UserId, BrickCount.Value) deathcount.Value = ds2:GetAsync(plr.UserId) or 0 ds2:SetAsync(plr.UserId, deathcount.Value) deathcount.Changed:connect(function() ds2:SetAsync(plr.UserId, deathcount.Value) end) end) end) game:GetService("Players").PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1 end) end) end)
thanks
If the death's count get reset when you leave, i have a solution, try this script. Sorry that this is completely different (I have a script that saves the stats in my game).
local severStorage = game:GetService("ServerStorage") local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSave3") --------------Stats-------------- game.Players.PlayerAdded:Connect(function(player) --------------leaderstats and dataFolder-------------- local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local dataFolder = Instance.new("Folder") dataFolder.Name = player.Name dataFolder.Parent = severStorage.RemoteData --------------DeathStats-------------- local deaths = Instance.new("StringValue") deaths.Name = "Deaths" deaths.Value = DataStore:GetAsync(player.UserId).Deaths or "0" deaths.Parent = leaderstats player.CharacterAdded:Connect(function(char) local humanoid = char:FindFirstChild("Humanoid") humanoid.Died:Connect(function() wait(0.001) deaths.Value = deaths.Value + 1 end) end) end) --------------SavingTheStats-------------- game.Players.PlayerRemoving:Connect(function(Player) DataStore:SetAsync(Player.UserId, { ["Deaths"] = Player.leaderstats.Deaths.Value; }) end)
Hoped This worked :)