Best Scripting Practices?

Does anyone have a list of basic scripting practices that should be followed? I hate to say this, but I fell victim to this horrible practice of parenting before setting the properties: PSA: Don't use Instance.new() with parent argument

I would like to know if there are any other common practices that everyone should know.

2 Likes

Please search before posting.

https://devforum.roblox.com/search?q=best%20scripting%20practice

You get tons of results. Some are a little specific but they get the point across.

2 Likes

These are a few good reads on bad practices

In addition to this a few things that you should do

  1. All services should be referenced using game:GetService (not necessary for workspace as it is a property of game)
  2. When importing a module, use the name of the module for its variable name.

And a few things that apply to programming in general

  1. Add comments where necessary
  2. Design before coding
  3. Avoid optimization if it makes your code harder to read
  4. Don’t copy-and-paste code from other people or websites without fully understanding what it is doing
1 Like