4

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.

  • no further hints, like line number? – Marcus Müller Jun 04 '15 at 22:46
  • I'm not a Lua pro, but I think the `..` on the third line looks suspiciously like a syntax error. – elixenide Jun 04 '15 at 22:46
  • Nope. But It doesn't matter much because I only call that command once in the whole script, and running the individual comman "message.Destroy" gets the exact same error. So it has something to do with that particular command. – Wingless Wallaby Jun 04 '15 at 22:48
  • Ed It is not. The .. is replaced with the player name which is determined by some earlier code. Also when the message appears on the screen .. is filled in by the player's name just fine. It is only the deleting of the message that isn't working. – Wingless Wallaby Jun 04 '15 at 22:50
  • `..` is the concat operator. It isn't "replaced" by anything. That's what the `playerName` variable is. – Etan Reisner Jun 04 '15 at 23:13
  • What does the `message.Destroy` look like/do? – Etan Reisner Jun 04 '15 at 23:14
  • Can you show us/link to the entire file that this code is in? (That lua reports the error is coming from?) – Etan Reisner Jun 04 '15 at 23:15
  • The `message.Destroy` command will remove the pop up message telling who won the race. – Wingless Wallaby Jun 04 '15 at 23:34
  • Got the code file. http://pastebin.com/XP4PGX8r Line 70 is the command that is giving me trouble. – Wingless Wallaby Jun 04 '15 at 23:45
  • If you comment out line 70, does it still return the error? Trial and error suggests that you comment all lines out until you stop receiving the error. Then you can debug it further that way. – Josh Jun 05 '15 at 00:55
  • I already know what is causing the issue. I just don't know how to fix it. The `message.Destroy` command when run by itself returns the exact same error. I just don't know how to fix that command. It is the exact same command i have seen in tutorials. – Wingless Wallaby Jun 05 '15 at 01:42

3 Answers3

4

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.

Richard Chambers
  • 14,509
  • 3
  • 62
  • 86
2

Instead of message.Destroy() it should be message:Destroy()

Remember that '.' are used directory-wise and ":' are used for inbuilt functions.

1

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

  • I am an idiot. It uses a colon everywhere. If i had looked carefully I would have seen the answer to my problem all over the code! Oh wow. I am laughing so hard right now. Anyways, thanks all you guys for your help. I was really impressed with how quickly i was getting suggestions. Thanks again, and maybe I will help one of you out someday. – Wingless Wallaby Jun 05 '15 at 02:45