#deathcounter leaderstat save
20 messages · Page 1 of 1 (latest)
we need to hack him, and read the code from his pc
🤣🤣
No way some of these people aren't trolling...
mb lol
DeathCounter:
game.Players.PlayerAdded:Connect(function(players)
local leaderboard = players:WaitForChild("leaderstats")
leaderboard.Name = "leaderstats"
local Deaths = Instance.new("IntValue", leaderboard)
Deaths.Name = "Deaths"
Deaths.Value = 0
players.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
Deaths.Value = Deaths.Value + 1
end)
end)
end)
DataStore
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local deathsKey = player.UserId.."-Deaths"
local deaths = 0
local success, error = pcall(function()
deaths = dataStore:GetAsync(deathsKey) or 0
end)
if success then
leaderstats.Deaths.Value = deaths
else
warn("Failed to retrieve data: " .. error)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local deathsKey = player.UserId.."-Deaths"
local success, error = pcall(function()
dataStore:SetAsync(deathsKey, leaderstats.Deaths.Value)
end)
if not success then
warn("Failed to save data: " .. error)
end
end
end)
i was playing lol i forgot
😭
you create a new int in each player shitting adding
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
leaderstats.Name = "leaderstats"
local deathsKey = player.UserId.."-Deaths"
local deaths = 0
local success, error = pcall(function()
deaths = dataStore:GetAsync(deathsKey) or 0
end)
if success then
local Deaths = Instance.new("IntValue", leaderstats)
Deaths.Name = "Deaths"
Deaths.Value = deaths
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
Deaths.Value = Deaths.Value + 1
end)
end)
else
warn("Failed to retrieve data: " .. error)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local deathsKey = player.UserId.."-Deaths"
local success, error = pcall(function()
dataStore:SetAsync(deathsKey, leaderstats.Deaths.Value)
end)
if not success then
warn("Failed to save data: " .. error)
end
end
end)
wdym
** You are now Level 1! **
-- DeathCounter
game.Players.PlayerAdded:Connect(function(players)
local leaderboard = players:WaitForChild("leaderstats")
leaderboard.Name = "leaderstats"
local Deaths = Instance.new("IntValue", leaderboard)
Deaths.Name = "Deaths"
Deaths.Value = 0
players.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
Deaths.Value = Deaths.Value + 1
end)
end)
end)