So I wanted to make a death leaderboard with autosave for me game, so I made this script:(Someone else's script)
--This script was made by ROBLOXSCRIPT ISEASY
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Deaths") -- Change this with a random name.
game.Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local Currency = Instance.new("IntValue", Leaderstats)
Currency.Name = "Deaths" -- Change this with your currency name.
Currency.Value = 0
local humanoid = char:FindFirstChild("Humanoid")
humanoid.Died:Connect(function()
Deaths.Value = Deaths.Value + 1
local Data = DataStore:GetAsync(Player.UserId)
if Data then
Currency.Value = Data
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, Player.leaderstats.Deaths.Value)
end)
The death counter works, but the autosave does not. Will you help me?

2 comments
Don't forget to click "view 25 more"
So know one?