So i'm making a machine that converts your resource to money at a tick rate of every second. The issue is that when the tick rate is 4 per second, and your starting amount is 30, you get -2. Now, to combat this, I made this script:
local plr = script.Parent.Parent.Parent.Parent
if plr and plr:FindFirstChild("Owner") then
plr = plr.Owner.Value
end
script.Parent.Changed:Connect(function(v)
print("The change of amountHolding is: "..v)
if script.Parent.Value < 0 then
plr.leaderstats.Money.Value += math.abs(script.Parent.Value)
script.Parent.Value = 0
end
end)
I've tried everything. If you know why I get the error please answer

1 comment
Change it in the script that subtracts from the leadervalue instead of making a new one specifically to handle this case.