I’m trying to optimize my script a little bit, and a question came up. I decided to use a lot of functions to make the code easier to read and look cleaner. So, for example, I’d do…
local function DeleteOldInstances()
if Player:FindFirstChild("Quest") then
Player.Quest:Destroy();
end;
if Player:FindFirstChild("NoExp") then
Player.NoExp:Destroy();
end;
end;
-- then, maaany lines later
DeleteOldFolders();
…instead of directly writing down the block of code
if Player:FindFirstChild("Quest") then
Player.Quest:Destroy();
end;
if Player:FindFirstChild("NoExp") then
Player.NoExp:Destroy();
end;
I do this mainly so I can collapse the functions and shorten the lines so I can work better on other, more important code.
I’m guessing it’s the same thing but I always prefer asking stuff I am not sure about.