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

I need to set a limit on the value?

Asked by
DevingDev 346 Moderation Voter
8 years ago

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)
0
Change line 10 to: "if Units.Value > 50 then" (without the quotation marks, ofc). Also fix your grammar so others can understand you better. TheDeadlyPanther 2460 — 8y
0
I'd suggest checking your grammar on this question. I wish I could answer it, but you've made some grammar errors. GiveMeYourPudding 64 — 8y
0
got it working thanks "TheDeadlyPanther" DevingDev 346 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question