ROBLOX Lua Error in script: '=' expected near '<eof>' - lua

Hello I am writing a scipt on ROBLOX and I have encountered a problem.
function showVictoryMessage(playerName)
local message = Instance.new("Message")
message.Text = playerName .." has won!"
message.Parent = game.Workspace
wait (2)
message.Destroy()
end
Upon running this function, or more specifically the "message.Destroy" command, I get the error: Error in script: '=' expected near '< eof >'
I have never seen this error before, and the ROBLOX wiki page on Lua errors doesn't mention it.
I would very much appreciate help in this, because I don't personally know anyone who has coded in Lua.

Looks like a syntax error. message.Destroy() should be message:Destroy() according to this Roblox wiki page http://wiki.roblox.com/index.php?title=API:Class/Instance/Destroy
Also see the section Explosions, Messages, and More at URL http://wiki.roblox.com/index.php?title=Basic_Scripting which provides similar syntax using the colon (:) operator.
See also Difference between . and : in Lua and explanation of "possible side-effects of calculations/access are calculated only once" with colon notation.

Instead of message.Destroy() it should be message:Destroy()
Remember that '.' are used directory-wise and ":' are used for inbuilt functions.

WOOOOOOOO! It was a syntax error. The correct command is message:Destroy. Cause why would object.Destroy work and message.Destroy not?

Related

F# FSI "Unexpected compiler generated literal in interaction" with "#I __SOURCE_DIRECTORY__"

If I create a new F# file 'Test.fsx' in VSCode with the line
#I __SOURCE_DIRECTORY__
attempting to run the code in FSI generates the error
Test.fsx(2,4): error FS0010: Unexpected compiler generated literal in interaction. Expected incomplete structured construct at or before this point, ';', ';;' or other token.
Any idea what might be going wrong?
It is a known issue in VS2019, which has been fixed in VS2022.
https://github.com/dotnet/fsharp/issues/13467
You may replace the code with
#I "."

How do I find the error details using the match function on Lua?

I'm just asking a question on finding error details from the error function.
Like I would like to find error details from example.lua:50: "then" expected near "if".
Any ways on how to do that on Lua? I'm working on something for ComputerCraft on Lua. (Minecraft Java mod)
EDIT:
I'm trying make a function that returns the error parsed out. It's supposed to return 3 variables, var1: file name, var2: line number (if none it is specified nil), var3: error text.
example.lua is the file where the error is. 50 is the line number. There is a syntax error, likely in the if condition. (I'm not familiar with ComputerCraft, so I don't know where that file might be.)

Syntax error running "Hello World" in Atom Editor using Love2d

I'm just getting started with Lua Love and just tried running
function love.draw()
love.graphics.print("Hello World")
end
When running the code in Atom Love opens showing the error
Syntax error: main.lua:1:''expected near'.'
What is causing the error and how can I fix it please?
Sorry guys, I had initially function.love.load() and deleted the dot between function and love BUT did not save the file thereafter. UUps

Lua Compiling Error 'do' expected near '['

I have a Lua file that I decompiled using unluac. When I try to recompile the files without any changes I get the following error:
lua: main.lua:647: 'do' expected near '['
I really do not know the problem here, as the while do statement follows the correct format.
The error is on line 647 as stated above.
Source is here:
Full Pastebin Source
Expressions like while {}[1] do and if {}[1].parentFolderName then are invalid because of {}[1] reference. It needs to be ({})[1]. It's probably a result of some sort of automated processing, but you should be able to fix it manually.

<eof> expected near 'end'

I'm using these files in my gaming server, and every time I add a new player model, I get
[ERROR] lua/autorun/server/fastdlskins.lua:938: '<eof>' expected near 'end'
1. unknown - lua/autorun/server/fastdlskins.lua:0
I also get a similar error when I add an add-on to a different file
[ERROR] lua/autorun/server/workshopitems.lua:55: '<eof>' expected near 'end'
1. unknown - lua/autorun/server/workshopitems.lua:0
I usually just have to put an 'end' after the code, but I don't see what else I'm required to do. I don't have any loops running (I think), so I'm not closing any of those out. Not sure what to do.
As Egor said, remove the extra end at the end of the files.
end is only used to close blocks for functions and loops, like } in C-like languages. The end at the file is not closing anything, and is thus invalid syntax.

Resources