Jump to content

<name> expected near message


Hiding

Recommended Posts

Hello, I'm wondering why throw this error message? <name> expected near '" Some message"'

 

local messages = {
    message1: " Some message",
    message2: " Some message2",
}
 
outputChatBox(messages.message1, source, 255, 255, 255, true)
Edited by Hiding
Link to comment
  • Hiding changed the title to <name> expected near message

It's a syntax issue -- you're not supposed to use a colon to separate the key from the value in a table. The correct character is an equals sign:

 local messages = {
    message1 = " Some message",
    message2 = " Some message2",
} 

I believe "<name> expected" is referencing OOP style calls like SomeObject:someMethod(), (the only use of the colon in Lua that I can recall of the top of my head), as if you wrote :someMethod() without any object name in front, but Lua expects a object name there.

Edited by Addlibs
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...