local number = 1
local clickDetector = script.Parent
clickDetector.MouseClick:Connect(function()
local wChildren = game:GetService("Workspace"):GetChildren()
for i,c in pairs(wChildren) do
if string.sub(c.Name, 1, 2) == "FM" then
c.Parent = game.Lighting
local fm = 'FM'..number
if game:GetService("Lighting"):FindFirstChild(fm) then
local fm1 = game:GetService("Lighting"):FindFirstChild(fm)
fm1.Parent = game:GetService("Workspace")
print(fm)
number = number + 1
else
local number = 1
print('FM'..number)
end
end
end
end)
the problem is that it won't continue with the if loop, it just stops in the else statement, but I want it to go with the loop
this is the entire output
FM1 FM2 FM3 FM4 FM5 FM6 FM7 FM8 FM9 FM1
why doesnt it go back to FM1 and then loop the output again?

3 comments
You need to check for when "number" equals 9, then set it back to 1.
No. There is 9 folders in my Lighting and I already do that by checking if there is a 10th folder or not, but there isn't, so it is supposed to start the 1-9 loop again from 9.
what are you trying to do?