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)