Script not checking player's cash, How to fix?
Hello. So im trying to make a script to make the player upgrade his Bread Factory. but when i click the button it does not work! The build part works (to build the bread factory) but the upgrade part not. it doesnt check player stats for some reason (Cash).
01 | local model 1 = script.Parent.Parent.Parent.brick 1 |
03 | local MoreCash = script.CC.Value |
04 | local factory = script.Parent.Parent.Parent |
05 | local isUpgrading = false |
06 | model 1. Parent = game.Lighting |
07 | local model = game.Lighting.brick 1 |
10 | script.Parent.ClickDetector.MouseClick:Connect( function (poeple) |
11 | if poeple.Name = = factory.OwnerName.Value then |
12 | if isUpgrading = = false then |
13 | if game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value > = Upgradecost then |
14 | game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value = game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value - Upgradecost |
15 | model.Parent = workspace |
16 | game.Players:FindFirstChild(poeple.Name).PlayerGui.bred.Enabled = true |
19 | script.Parent.SurfaceGui.TextLabel.Text = "Upgrade-$" .. Upgradecost |
22 | if game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value > = Upgradecost then |
23 | Upgradecost = Upgradecost * math.random( 2 , 3 ) |
24 | script.Parent.SurfaceGui.TextLabel.Text = "Upgrade-$" .. Upgradecost |
25 | game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value = game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value - MoreCash |
it keeps printing 'oof' (i added that so i could know if its because of the stat)
It should increase the price when upgrading