Cannot run code through the lua_code entity

So I think I’ve run into a major problem with the lua_run entity.
I have a logic_auto entity that has the following output:

“OnMapSpawn” "LuaEntity,RunPassedCode,game.ConsoleCommand("sv_gravity 400
“),0,-1”

The problem is Hammer will crash because it can’t parse the extra quotation marks inside of game.ConsoleCommand() properly.
If I try to switch the quotes to single quotes like so:

“OnMapSpawn” “LuaEntity,RunPassedCode,game.ConsoleCommand('sv_gravity 400
'),0,-1”

This prints out to console:

[ERROR] RunString:1: unfinished string near '‘sv_gravity 400’

  1. unknown - RunString:0

Please help, I have no idea what to do.

Try using [[ and ]] instead of ’ to specify the string. Like this: [[sv_gravity 400]]

Also, is the
necessary for the code to work? Try it without.

Alternatively you could use the point_servercommand entity.

That worked! Beautiful, thanks so much. Yeah I normally would just use point_servercommand but that entity is disabled in gmod (I still don’t get why, they said it was for security purposes but you can do basically the same things using the lua_run entity)

Also yes the newline character is needed for the ConsoleCommand() function or it won’t parse the command properly.