Trying to switch leaderstats

i edited a script i got but it wont work. i am trying to switch a player’s leaderstats when they touch a part but it only makes a leaderstat 0. the script is:

   local Players = game:GetService("Players")
    local sellpart = script.Parent
    local function onPartTouch(otherPart)
    	local partParent = otherPart.Parent
    	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    	if humanoid then
    		local player = Players:GetPlayerFromCharacter(partParent)
    		local leaderstats = player.leaderstats
		local milkStat = leaderstats and leaderstats:FindFirstChild("milk")
			local moneyStat = leaderstats and leaderstats:FindFirstChild("MONEY")
    		if milkStat and moneyStat then
			moneyStat.Value = milkStat.Value
			milkStat.Value = 0
    		end
    	end
    end
    sellpart.Touched:Connect(onPartTouch)

By switch I’m guessing you mean swap 2 leaderstat values? If so, try this

local Players = game:GetService("Players")
local sellpart = script.Parent

local function onPartTouch(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		local player = Players:GetPlayerFromCharacter(partParent)
		local leaderstats = player.leaderstats
		local milkStat = leaderstats and leaderstats:FindFirstChild("milk")
		local moneyStat = leaderstats and leaderstats:FindFirstChild("MONEY")
		if milkStat and moneyStat then
			local milkVal = milkStat.Value 
			local moneyVal = moneyStat.Value
			moneyStat.Value = milkVal
			milkStat.Value = moneyVal
		end
	end
end

sellpart.Touched:Connect(onPartTouch)

It first stores their values and then places them in the opposite areas