Hello there, can someone help me fix the script. Everything works fine, but leaderboard deaths don't count. The script is
local dss = game:GetService("DataStoreService")
local obbyDS = dss:GetDataStore("ObbyData")
local deathsDS = dss:GetDataStore("DeathsData")
local checkpoints = workspace.Checkpoints
game.Players.PlayerAdded:Connect(function(plr)
local obbyData = obbyDS:GetAsync(plr.UserId .. "-obbyStageProgress")
local deathsData = deathsDS:GetAsync(plr.UserId .. "-deaths")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = plr
local stage = Instance.new("StringValue")
stage.Name = "Stage"
stage.Value = obbyData or 1
stage.Parent = ls
local wipeouts = Instance.new("IntValue")
wipeouts.Name = "Deaths"
wipeouts.Value = deathsData or 0
wipeouts.Parent = ls
local char = plr.Character or plr.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
char.Humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
stage.Value = touch.Name
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end
end
end)
char.Humanoid.Died:Connect(function()
wipeouts.Value = wipeouts.Value + 1
deathsDS:SetAsync(plr.UserId .. "-deaths", plr.leaderstats.Deaths.Value)
end)
plr.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
hrp:GetPropertyChangedSignal("CFrame"):Wait()
hrp.CFrame = checkpoints[stage.Value].CFrame
humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
stage.Value = touch.Name
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end
end
end)
end)
end)

2 comments
Could you provide a little more context than posting the whole script and saying that it doesn't work? Are there any output errors? What are you doing with DataStore? The more information you provide, the easier it is for people to help you.
There are no errors, in leaderboard when i die deaths count once and when i die for second time it dont count. The script start at line 44.