Is there a way I can code in my own game?

Is there a way I can script in my own game, similar to f3x letting players build ingame?
I know about the command line thing,


But, I’d like to mess around with code ingame, with my friends, and test it as im writing it. Is this possible?

yes. all you need to do is go to studio and insert a script and you should be able to begin but ingame just press F9 press server(if you are the game owner/developer) and go to the commandline also what @incapaz said

1 Like

Yes, you will want to enable loadstring via the property LoadStringEnabled of ServerScriptService. Since loadstring can only be used by the server you will need a remote event, and you will want to make sure that only the developer(s) of the game can use it and possibly whitelist some friends.

5 Likes

to be honest, you would probably have the best experience just using team create.

To allow players to use code in game you would have to enable and use loadstring()

As for building its a case of creating new parts and having a good gui and kepbind system

1 Like

To put it simply, you can just use loadstring() on the content of a TextBox. Or, you can opt for the tricky route and included syntax highlighting and the prevention of malicious code.

For the complex method, you will need:

  • A lexical analyser (lexer). There is an open source one available here.
  • A highlighting module, this simply creates Text Labels behind the text to make it nice and colourful.
  • A protection system for executing code. There is an open source one available here.

Great, but what is a lexer?
A lexer is a module that identifies what stuff is. Basically, it returns tokens that have information on the text you ran on it. For example, / would return operator.

1 Like