ROBLOX Lua error in script: '=' expected around '<eof>'

Hello I am writing scipt on ROBLOX and I am facing a problem.

function showVictoryMessage(playerName)
    local message = Instance.new("Message")
    message.Text = playerName .." has won!"
    message.Parent = game.Workspace
    wait (2)
    message.Destroy()
end

      

After running this function, or more specifically the "message.Destroy" command, I get an error: Error in script: '=' expected near <eof> '

I've never seen this error before, and the Wiki page on ROBLOX on Lua Errors does not mention it.

I would really like to help with this, because I personally don't know anyone who is coded in Lua.

+3


source to share


3 answers


It 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 Explosions, Messages, and More section at http://wiki.roblox.com/index.php?title=Basic_Scripting , which provides a similar syntax using the colon (:) operator.

+3


source


Instead, message.Destroy()

it should bemessage:Destroy()



Remember this. are used in different ways, but ":" are used for builtins.

+2


source


WOOOOOOOO! It was a syntax error. The correct team message:Destroy

. The reason why object.Destroy

work and post .Destroy

not?

+1


source







All Articles