Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this while loop not start running?

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?

1 comment

0

I can assume the starting value of "BatteryLeft.Value is 100?

1 answer

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

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.