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
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
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 :/