Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script not checking player's cash, How to fix?

Asked by 4 years ago

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).

01local model1 = script.Parent.Parent.Parent.brick1
02local Upgradecost = 0
03local MoreCash = script.CC.Value
04local factory = script.Parent.Parent.Parent
05local isUpgrading = false
06model1.Parent = game.Lighting
07local model = game.Lighting.brick1
08wait()
09 
10script.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
View all 33 lines...

it keeps printing 'oof' (i added that so i could know if its because of the stat) It should increase the price when upgrading

1 answer

Log in to vote
0
Answered by 4 years ago

For some reason u have "else" in line 21 of your script. That's why script ignores the nex part of code: because conditions of "if" was accepted,"else" will never work in this situation.

Ad

Answer this question