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

"Workspace.Tool.Script:15: 'end' expected (to close 'function' at line 12) near 'else'"?

I'm trying to make a tool that burns whatever bricks you click on. Currently returns " Workspace.Tool.Script:15: 'end' expected (to close 'function' at line 12) near 'else'"

function Burn(part)
	print "burning part"
	fire = Instance.new("Fire")
	fire.parent = part 
	for burning=0,1, 0.1 do
		wait(1)
		part.Transparency = burning
	end
	part:Destroy()
end

function Button1Down(mouse)
	setfireto = mouse.Target
	if setfireto ==  nil then return end
	else Burn(setfireto)
	end
end

1 comment

0

The second problem in your code is that 'parent' on Line 4 is not capitalized - I think that fixes the problem.

3 answers

The problem is at line 14. "else" only works inside of if statements. So, Instead of:

 if setfireto ==  nil then return end
    else Burn(setfireto)

do:

if not setfireto then
return
else
Burn(setfireto)
end

Also, in case you're wondering, you don't have to check if a value is nil by doing var == nil, you can just do not var

So, instead of:

L = 0
print(L == nil)
--Output: false

you can simplify it by adding "not" before the variable like this:

L = 0
print(not L)
--Output: false

2 comments

0

The error stopped, but the tool still does nothing. Any idea why?

0

line 4, the P in parent should be capitalized

You need to capitalize the P in: Fire.parent

Make it like:

Fire.Parent

Good luck ;)

if its a function error where end expected at line 12 cuz you need a end on line 18 :/

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