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).
local model1 = script.Parent.Parent.Parent.brick1 local Upgradecost = 0 local MoreCash = script.CC.Value local factory = script.Parent.Parent.Parent local isUpgrading = false model1.Parent = game.Lighting local model = game.Lighting.brick1 wait() script.Parent.ClickDetector.MouseClick:Connect(function(poeple) if poeple.Name == factory.OwnerName.Value then if isUpgrading == false then if game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value >= Upgradecost then game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value = game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value - Upgradecost model.Parent = workspace game.Players:FindFirstChild(poeple.Name).PlayerGui.bred.Enabled = true isUpgrading = true Upgradecost = 5 script.Parent.SurfaceGui.TextLabel.Text = "Upgrade-$".. Upgradecost end else if game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value >= Upgradecost then -- error is here Upgradecost = Upgradecost * math.random(2,3) script.Parent.SurfaceGui.TextLabel.Text = "Upgrade-$".. Upgradecost game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value = game.Players:FindFirstChild(poeple.Name).leaderstats.Cash.Value - MoreCash else print("oof") end end end end)
it keeps printing 'oof' (i added that so i could know if its because of the stat) It should increase the price when upgrading
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.