I am working for my game, I need help with the leaderstats to track my deaths. There are 2 data values, "Rip's" and "TotalRips" (DataStore), it is working, almost. Although it appears to be working, the problem is the first death doesn't count towards the TotalRips Count, after that it works. I put these 2 scripts in here:
local deathsStore = game:GetService("DataStoreService"):GetDataStore("TotalRips")
function playerAddedHandler(plr)
local playerKey = "Player_" .. plr.UserId
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local TotalRips = Instance.new("IntValue", leaderstats)
TotalRips.Name = "TotalRips"
TotalRips.Value = deathsStore:GetAsync(playerKey)
plr.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
plr.leaderstats.TotalRips.Value = plr.leaderstats.TotalRips.Value + 1
local success, err = pcall(function()
deathsStore:SetAsync(playerKey, plr.leaderstats.TotalRips.Value)
end)
end)
end)
end
game.Players.PlayerAdded:Connect(playerAddedHandler)
Also here is another one of the script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats
if player:FindFirstChild("leaderstats") then
leaderstats = player.leaderstats
else
leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end
local Rip = Instance.new("IntValue")
Rip.Name = "Rip's"
Rip.Parent = leaderstats
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
Rip.Value = Rip.Value + 1
end)
end)
end)
I need help because it could be inaccurate for accounting these values.

1 comment
I am sorry but it didn't work, when i paste the code it said: Error: (11,13) Syntax error: Expected identifier when parsing expression, got '['. The Rip's Count is working, put the TotalRips isn't.