How to Change the Players leaderstats to zero when they die

Im making a game where if the player dies their checkpoint are reset i got the Datastore working along with the checkpoint system but im having issues here not knowing how to write such script here is where i left off please help me!

local RPS = game:GetService(“ReplicatedStorage”)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Humanoid = Character:WaitForChild(“Humanoid”)
local DeathEvent = RPS.Events.DeathEvent

You can use the Humanoid.Died listener to do something on player death

you could do something like

local RPS = game:GetService(“ReplicatedStorage”)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Humanoid = Character:WaitForChild(“Humanoid”)
local DeathEvent = RPS.Events.DeathEvent

Humanoid.Died:Connect(function()`
       DeathEvent:FireServer()
end)

afterwards just change the leaderstats value of the player in a server script

Hi again. In order to achieve this, simply do something like the following in a server script:

game.Players.PlayerAdded:Connect(function(plr)plr.CharacterAdded:Connect(function(c)
    c:WaitForChild("Humanoid").Died:Connect(function()
        -- reset leaderstats
    end
end)end)
local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			local _stats = player.leaderstats
			for _, stat in ipairs(_stats:GetChildren()) do
				if stat:IsA("NumberValue") or stat:IsA("IntValue") then
					stat.Value = 0
				end
			end
		end)
	end)
end)