Cash = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Coins mcost = script.Parent.Cost.Value function onClick() if Cash.Value >= mcost then Cash.Value = Cash.Value - mcost game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 150 end end script.Parent.MouseButton1Click:connect(onClick)
it works with subtracting the amount of cash it cost but it's not changing the maxhealth to 150
You can try doing this script:
local Cash = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Coins local mcost = script.Parent.Cost local plr = game.Players.LocalPlayer function onClick() if Cash.Value >= mcost.Value then Cash.Value = Cash.Value - mcost.Value local hum = plr.Character:FindFirstChild("Humanoid") hum.MaxHealth = 150 end end script.Parent.MouseButton1Click:connect(onClick)
Having the Value of an object in a variable won't work. Also try to correctly indent your script, it makes more easier to read, understand and avoids causing errors.