I realized a major flaw in my scripting while practicing. It is organizing the script and keeping it clean. Any tips on how to organize my script better or keeping it clean? I also have trouble knowing where to put certain scripts.Thanks!
I would suggest just writing better code?
There may be something similar to BeautifulSoup like Python has, but for what reason?
Just remember to indent, have good variables, and shorten the code. Problem solved.
Comments (don’t over use them), whitespace, indents, and good variable names can make a program barely readable to being able to understand what a section does in an instant.
I used to do “temporary” variables (calling them a and b) which makes it more confusing. Comments can help to understand what each section of the code and whitespace can separate code into sections. Before I learned Lua and only knew Python I had to rewrite a program which was about 30 lines long because I didn’t do any comments, whitespaces and I used bad variable names.
Thanks! I will start adding comments to my script.
Server scripts can be anywhere, while local scripts can only be in a Player’s GUI, their backpack, tools, and what not. I’d recommend what the other people said, good variable names, try and shorten code as much as possible to save on memory, and indents too, and use comments to know how the code works (don’t use too much of them:
I like to organize my scripts similar to the following, starting with a small comment describing the purpose of the script etc, and then variables and anything else.
-- // MainUI Controller \\
-- // Used for controlling the main UI menu. \\
-- // By AviaSkip, 19/12/2020 \\
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
Players.PlayerAdded:Connect(function(plr)
warn("some noob joined!")
end)
You get the point, I also don’t like to use single letters as variables (like i, v etc) as it can be hard to understand without knowing what the variable is for. I also try not to use too many comments if possible, sometimes I just comment code that I don’t end up using, but just leave it there which can be pretty messy.