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

Variable is not getting set every time this While loop runs?

Ok, I know ive done this before but I cant find where,

while FuelLelf == true do
		print(CurrentFuel)
		local CurrentFuel = CurrentFuel - FuelDecreaseNum 
		print(CurrentFuel)
		wait(.3)
	end

In my mind, because that's happening, and every time CurrentFuel is being decreased, every time it runs the fuel will be a lower number than the last time it ran. However, I only get "100 90 100 90" in the output. So im not sure what's happening.

1 answer

✓ Accepted answer

You're using local, which is telling the script to use a variable that will not been seen as 90 outside of the loop. Inside of the loop it is constantly changed to 90 because of this local declaration. You can just remove the local and the code should work fine.

1 comment

0

Ah, thanks

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