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

I have problems with infinite loops (MORE INFO IN DESCRIPTION) ?

So, i want X value (9.5 in my case) to drop down to 9 (x = x - 0.01) but when it reaches value of 9, to rise to 9.5 again (x = x + 0.01). That loop should repeat infinite times.

I've tried several thing but none of them worked. I really hope that some of you pro scripters can help :)

1 comment

0

there is this cool thing called a while loop.. try using it

1 answer

Are you using if statements such as if X >= 9.5 then and if X <= 9 then?

If not you should consider using it to check the value of X. Using what I just said I did something like this:

while wait(0.1) do -- In the wait, put the seconds you want to pause between each loop

	if X <= 9 then -- Check if X is less than or equal to 9

		X = X + 0.01 -- Add 0.01 to X

	elseif X >= 9.5 then -- Check if X is more than or equal to 9.5

		X = X - 0.01 -- Subtract 0.01 to X

	end
end

2 comments

0

Didn't really help. I get weird numbers in the output.

0

this script should work though

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