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

End expected to close ' for' at line 3?

In the output I keep getting Workspace.Part.SurfaceGui.TextButton.Script:12: 'end' expected (to close 'for' at line 3) near 'for'

b = script.Parent
b.MouseButton1Click:connect(function()
for n = 0,1,0.1 do
			wait(0.1)
	b.BackgroundTransparency =n
	b.TextTransparency = n
	break	
--	if b.BackgroundTransparency ==0
--		and b.TextTransparency ==0
--		then 
--wait(5)
		for i = 1,0,-0.1 do
	wait(0.1)
	b.BackgroundTransparency =i
	b.TextTransparency = i
	break
		end
		end
end)

2 answers

✓ Accepted answer

if the sytsem tells u close it, then close it... that's the thing I'd actually recommend most, Listen to the Output

b = script.Parent
b.MouseButton1Click:connect(function()
for n = 0,1,0.1 do
            wait(0.1)
    b.BackgroundTransparency =n
    b.TextTransparency = n
    break   
--  if b.BackgroundTransparency ==0
--      and b.TextTransparency ==0
--      then 
--wait(5)
end --closes 'for' above, loops need an end just like functions and if's
        for i = 1,0,-0.1 do
    wait(0.1)
    b.BackgroundTransparency =i
    b.TextTransparency = i
    break
        end
        end
end)

1 comment

0

Also, if u ever need to kno ho to put a function under another function, then u'll find the Anser in the 'end's

Workspace.Part.SurfaceGui.TextButton.Script:12: 'end' expected (to close 'for' at line 3) near 'for' In other words you forgot an end it happens to me a lot.

    for i= 1,1,0.1 do
      -- code
 end 

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