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

How to make a function sequence?

How would I make a sequence? (For example, whenever the function activates, it'll cycle through each variable, returning to the original.) Is this even possible?

function Colors()
local a =  NumberSequence.new(1, 3) 
			if a == 1 then
			print'one'
			end
			
			if a == 2 then
			print'two'
			end
			
			if a == 3 then
			print'three'
			end

end

1 comment

0

Use a for loop inside a function.

1 answer

Use a for loop:

local NS = {1, 2, 3}

function Colors()
	for i = 1,#NumberSeq do -- Using a for loop goes through each number by one unless changed
		if i == 1 then
			print('one')
		elseif i == 2 then -- elseif goes through that if only for each loop
			print('two')
		elseif i == 3 then
			print('three')
		end
	end
end

event:connect(Colors) -- change the event to the event that should call the function

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