Ok so I am a messy scripter and some of yall maybe be too i suggest yall making cleaner scripts for example:
Part 1: Use Of Variables
script.Parent.Parent = script.Parent.Parent.Parent
This line above does look messy and for newly devs or non devs it is hard to understand
local Frame = script.Parent
local MainFrame = script.Parent.Parent.Parent
Frame.Parent = MainFrame
The code above this is easy to understand and can be easily manipulated
Part 2: Spaces
So the problem I face is when i make a huge code and when I have to change one thing i have to go find the line of the code to go change it (and yes i know there is something called find in roblox but i dont use it often)
it would be better using spaces
local event = game.ReplicatedStorage.event
local part = instance.new("Part")
part.Name = "Child Of Workspace"
part.Parent = game.Workspace
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(10,10,10)
The code above this is a bit messy you know
local event = game.ReplicatedStorage.event
local part = instance.new("Part")
part.Name = "Child Of Workspace"
part.Parent = game.Workspace
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(10,10,10)
The code above this is a better compared the the one with the above it
Part 3: Comments
Navigating can be tough in scripting luckly we have comments!
-- Hi! My name is comment. Nice to meet you fellow user!
Scripts like this one
local event = game.ReplicatedStorage.event
local part = instance.new("Part")
part.Name = "Child Of Workspace"
part.Parent = game.Workspace
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(10,10,10)
Might be easy but when you have bigger for almost 30-1000+ lines of code then comments are there to save your day!
Especially comment come in handy when making tutorials like this one!
local event = game.ReplicatedStorage.event -- Event
local part = instance.new("Part") -- Create new part
part.Name = "Child Of Workspace" -- Name our part
part.Parent = game.Workspace -- Parent our part
part.Anchored = true -- Anchor our part
part.CanCollide = false -- Make our part be able to phase through any object
part.Size = Vector3.new(10,10,10) -- Make our part a GIANT
The line above me is easy for newbies or non scripters to understand!
Part 4: Function Junction
So you may have heard of:
local part = script.Parent -- Part
part.Touched:Connect(function() -- Touch Function
-- Do Something
end) -- End
A very common function but there is a way around this and make it clean!
Fo example:
local function OnPlayerJoined(Player)
print(Player.Name) -- Print Name
end)
game.Players.PlayerAdded:Connect(OnPlayerJoined)
Now time for customizing
You can make custom function in roblox too!
Here is a script without a custom function:
local Decimal = 1.246810 -- Decimal number
print(math.floor(Decimal)) -- Rounding to the lowest value
Prints:
1
Heres one with a custom function:
local Decimal = 10.75 -- Decimal number
local function RoundDown(DecimalNumber) -- Custom Function
return math.floor(DecimalNumber) -- Returns our number
end) -- end
print(RounDown(DecimalNumber))
Prints:
10
Oh wow you made it to the end Congrats!
Hope this helped and please do not post any hate comments or report this was a family friendly tutorial for new players or players who want their script to be cleaner
Good Bye! Stay Safe