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
sjr04
(uep)
April 28, 2020, 4:46am
#2
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
This is an adaptation of a Twitter thread I made a while ago. This is simply a better formatted and more fleshed out version.
Let’s talk about wait(). Not wait(n) (although if you are using small n values to where it’d be barely distinguishable from wait(), you’re probably going to hit the same issues mentioned in this thread).
We probably learned about wait() at first as the solution to “why are my infinite loops crashing me?”. It’s a super easy solution and it works! This starts a bad habit…
Please do keep the following in mind before reading or linking!
Some parts of this thread provide slightly inaccurate, unnecessary or outdated information. You are strongly encouraged to read the replies for further discussion about FindFirstChild and WaitForChild and their use in code, as well as some pointers on replication.
I have not yet found a time to correct potential misconceptions in this thread. It does not provide authoritative advice and you should always double check information …
In addition to this a few things that you should do
All services should be referenced using game:GetService (not necessary for workspace as it is a property of game)
When importing a module, use the name of the module for its variable name.
And a few things that apply to programming in general
Add comments where necessary
Design before coding
Avoid optimization if it makes your code harder to read
Don’t copy-and-paste code from other people or websites without fully understanding what it is doing
1 Like