01 | Cash = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Coins |
02 | mcost = script.Parent.Cost.Value |
03 | function onClick() |
04 | if Cash.Value > = mcost then |
05 |
06 | Cash.Value = Cash.Value - mcost |
07 | game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 150 |
08 | end |
09 | end |
10 |
11 | script.Parent.MouseButton 1 Click: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:
01 | local Cash = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Coins |
02 | local mcost = script.Parent.Cost |
03 | local plr = game.Players.LocalPlayer |
04 |
05 | function onClick() |
06 | if Cash.Value > = mcost.Value then |
07 | Cash.Value = Cash.Value - mcost.Value |
08 | local hum = plr.Character:FindFirstChild( "Humanoid" ) |
09 | hum.MaxHealth = 150 |
10 | end |
11 | end |
12 |
13 | script.Parent.MouseButton 1 Click: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.