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

why doesnt this work?

Asked by
Jumbuu 110
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

i want it to add values to the energy value but it doesnt add

local tool = script.Parent
player = game.Players:GetPlayerFromCharacter(tool.Parent)

tool.Equipped:connect(function(Mouse)
    player = game.Players:GetPlayerFromCharacter(tool.Parent)
    local energy = player.PlayerGui.ScreenGui.Frame.Frame.Energy
    Mouse.Button1Down:connect(function()
        if energy.Value ~= 0  then
            energy.Value = energy.Value - 10
        end
    end)
    if energy.Value ~=100 then
        while true do
            energy.Value = energy.Value +1
            wait()
        end
    end
end)

0
You put a while true do statement, which will cause the energy to infinitely grow, since you've never broken the loop. Just saying as a little hint, for future reference. Shawnyg 4330 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Going off of what Shawnyg said, change the while loop to:

while true do
    if energy.Value =100 then
        break()
    end
    energy.Value = energy.Value +1
    wait()
end
0
i think the () adter break isnt supposed to be there but im not sure. just try taking them away if that doesnt work. iFireLazer 35 — 8y
Ad

Answer this question