Raymond Edwards
Raymond Edwards

Reputation: 1

unexpected symbol near )

unexpected symbol near ')' on Line 10

I am new to programming and have followed everything in "LUA Tutorial 10b"

hook.Add( "PlayerSay", "CommandIdent", function( ply, text, team )
  if( text == "!hurt" ) then
    ply:SetHealth( ply:Health() - 25 )
    if( ply:Health() <= 0 ) then
      ply:Kill()
    end
    return "OUCH!"
  end

  if( string.sub( text, 1, 4, ) == "/ooc" ) then
    return "[OOC]" .. string.sub( text, 5 )
  end

end )

The script should translate "/ooc (message)" to "[OOC] (message)" when a user types it in game.

Upvotes: 0

Views: 1604

Answers (1)

As stated by @char on the comments, apparently you've got an extra comma inline 10

if( string.sub( text, 1, 4, ) == "/ooc" ) then

It should be

if( string.sub( text, 1, 4 ) == "/ooc" ) then\

As stated in the lua wiki.

Upvotes: 1

Related Questions