So I am brand new to coding and I was following a Lua tutorial recently. He began to use the function command and I copied his line code exactly like he did and yet and error keeps occurring. Hopefully someone will be able to help thanks!
"Function" command not working
rwhite02760
#3
I just tried it and it still does not work. Also there is still a red ring around the function command and it says “matching bracket could not be found” I wish I wasn’t so new to coding!
0 Likes
OdatNurd
#4
Functions in lua
(and also conditional statements) end with the end
keyword, but you don’t have one. That’s why the error is at the bottom of the file and telling you that it expected to see an end
to close the function, but instead it found the end of the file.
function Factorial(number)
if number == 0 then
return 1
else
return number * Factorial(number - 1)
end
end
print(Factorial(5))
2 Likes