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

Why does this while loop not start running?

Asked by 10 years ago
while BatteryLeft.Value <= 100 and BatteryLeft.Value > 0 do
    game.Players[player.Name].PlayerGui.Battery.Frame.Bar1.Visible = false
    wait(1)
    game.Players[player.Name].PlayerGui.Battery.Frame.Bar1.Visible = true
end

BatteryLeft.Value does go below 100 but the while loop never runs. This happens all the time when I use a while loop xD

Can someone help?

0
I can assume the starting value of "BatteryLeft.Value is 100? Necrorave 560 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

I might sound like I don't know that much about scripting here but whenever I use while loops nothing happens. Unless it is because BatterLeft is an unknown variable to it because you did not do BatteryLeft =, I would reccoment doing this:

while true do
    if BatteryLeft.Value<=100 and BatteryLeft.Value>0 then
        game.Players[player.Name].PlayerGui.Battery.Frame.Bar1.Visible = false
        wait(1)
        game.Players[player.Name].PlayerGui.Battery.Frame.Bar1.Visible = true
    end
    wait(1)
end
0
Actually now that I think about it, I don't think you can just leave a while loop in a blank script, unless its while true do. I think if it is not true the first time it skips it, so you would have to put the while loop in another loop that constantly loops. PHIL528 0 — 10y
Ad

Answer this question