Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

lua

roblox

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.

like image 904
Wingless Wallaby Avatar asked Mar 15 '23 20:03

Wingless Wallaby


1 Answers

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.

like image 133
Richard Chambers Avatar answered Apr 07 '23 05:04

Richard Chambers