I tried to do line 22 and 23, but it won't work. It works fine with just changing the value, but I need it to be able to be adding not changing.
local touchers = {}
local DELAY = 5
function onTouched(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local plrTouching = false
table.foreach(touchers, function(key, val)
if val == plr then
plrTouching = true
end
end)
if not plrTouching then
table.insert(touchers, plr)
local stats = plr:findFirstChild("leaderstats")
local cash = stats:findFirstChild("Cash")
if cash.Value >= 150 then
cash.Value = cash.Value - 150
local MH = game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").MaxHealth --Maybe wrong
MH.Value = MH.Value + 50 --its not working
else
print("Not enough money!")
end
wait(DELAY)
for i = #touchers, 1, -1 do
if touchers[i] == plr then
table.remove(touchers, i)
end
end
end
end
end
script.Parent.Touched:connect(onTouched)

4 comments
Don't want to be rude, but try to explain what you've done in future to fix someone's code, otherwise there's no point in doing it as they can't learn from it...
I didn't how how I fixed it, that's why I didn't show how I fixed it, I was just playing around with those 2 lines
Lines 22 and 23 were changed
I understand it. so .Value is wrong. and has to be straight to MaxHealth, Thank you!