So, Ya im trying to set a limit so i cant the units value cant get over 50 this is wat i got so far . I dont know why its not working thats the hole script and this the part with "If Units.Value == 50 then Units.Value = Units.Value - 10" its there the limit im trying to set is not working.
Cash = Player.leaderstats.Cash Units = Player.leaderstats.Units function onClick() if Cash.Value >= 20 then Cash.Value = Cash.Value - 20 Units.Value = Units.Value + 1 local Barbarian = game.Lighting.Barbarian:clone() end if Units.Value == 50 then Units.Value = Units.Value - 10 end if Cash.Value <= 20 then script.Parent.NotEnough.Visible = true wait(2) script.Parent.NotEnough.Visible = false end end script.Parent.MouseButton1Click:connect(onClick)
Maybe use
Cash = Player.leaderstats.Cash Units = Player.leaderstats.Units
function onClick() if Cash.Value >= 20 then Cash.Value = Cash.Value - 20 Units.Value = Units.Value + 1 local Barbarian = game.Lighting.Barbarian:clone() elseif Cash.Value <= 20 then script.Parent.NotEnough.Visible = true wait(2) script.Parent.NotEnough.Visible = false end if Units.Value == 50 then Units.Value = Units.Value - 10 end end script.Parent.MouseButton1Click:connect(onClick)
They are both about Cash so I elseif'ed it.