Help with distance parcoured script

Hey devs (third time this week i write a post here lol),

I’ve been trying to make a system that checks how far the player went in the ground (making a mining game). To achieve that, I made a part that waits to get touched, and when it is, it goes 10 studs lower and changes a value in the ReplicatedStorage. The problem is that the part is getting touched multiple times in a row and that makes the part think that the players made a longuer distance. I don’t want to make a cooldown (with waits) because sometimes in the game you may fall fast and don’t have time to touch the part. The solution I found was the one below, but it doesn’t work, as always, any help is highly appreciated !

The script :

local partPosition = 0

script.Parent.Touched:Connect(function(hit)
	if partPosition ~= script.Parent.Position then
		if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
			partPosition = script.Parent.Position
			game.ReplicatedStorage.Distance.Value = game.ReplicatedStorage.Distance.Value + 1
			script.Parent.Position = script.Parent.Position + Vector3.new(0, -10, 0)
		end
	end

end)

You can use RunService’s Stepped event to capture the last frame player’s position and compare it to the current one, and you can probably raycast from the last position to the current position and get the position at when the raycast hits the ground.