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

This script keeps adding even when <= 38 (for a number value)?

Whenever the number value goes <= 38 it keeps adding then it stops after adding 100 times

This is in a billboard gui

Hierarchy

Script:

script.Parent.Parent.stormwinds.Changed:Connect(function()
	if script.Parent.Parent.stormwinds.Value <= 38 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0
			wait(0.1)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 39 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.001/10
			wait(0.1)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 74 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.01/10
			wait(0.1)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 96 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.01/10
			wait(0.01)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 111 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.02/10
			wait(0.01)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 130 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.03/10
			wait(0.01)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 157 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.04/10
			wait(0.01)
		end
	end
	if script.Parent.Parent.stormwinds.Value >= 500 then
		for i = 1, 100 do
			script.Parent.Value = script.Parent.Value + 0.05/10
			wait(0.01)
		end
	end
end)

5 comments

0

Why do you want to break on the first iteration of every for loop?

0

I was experimenting to see if break does anything, forgot to remove it.

0

I didn't know such a script was possible.

0

Whats the fix then?

0

well?

1 answer

It looks like your script will add 0 to the value 100 times with a 0.1 second interval between each addition. If you wish to just not add anything, simply don't check for that possibility. The value will not satisfy any of the other checks and the function will implicitly return.

1 comment

0

So then whats the fixed loop, im still confused with what the numbers do in for loops.

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