Hello members of the devforums, recently I was writing code and I just feel that is really sloppy. For me as the writer, it is easy to read but from time to time even I have trouble sometimes. I feel that if I gave this code to someone, it would be hard to understand besides the fact I leave notes to not confuse myself/others. Do any fellow scripters have advice on how to keep your code neat? Thanks. also an example of code I wrote is below. V
local IntermissionTime = 5
local RoundTime = 5
local Maps = workspace.Maps --folder of maps
local intermissionlocation = workspace.IntermissionLocation
local Values = game:GetService("ReplicatedStorage"):WaitForChild("Values")
local Teams = game:GetService("Teams")
local Red = Teams.Sentinels
local Blue = Teams.Mavericks
local TimeLeft = Values.RoundTime -- A timer for a gui to reference to
local InRound = Values.InRound -- not used in the script
local Players = game.Players
function TeamDistributor() -- the job of this script is to make sure that the teams are completely randomized and even.
for _, Player in pairs(game.Players:GetChildren()) do
task.wait(.1)
if #Red:GetPlayers() > #Blue:GetPlayers() then
Player.Team = Blue
elseif #Blue:GetPlayers() > #Red:GetPlayers() then
Player.team = Red
else
local Num = math.random(1,2)
if Num == 1 then
Player.Team = Blue
else
Player.Team = Red
end
end
end
end
while true do
for IntermissionTimer = IntermissionTime, 0, -1 do -- Job of IV Loop is to control the intermission
for _, player in pairs(game.Players:GetChildren()) do
player.Team = Teams.Intermission
end
wait(1)
TimeLeft.Value = "Intermission: "..IntermissionTimer
end
local ChosenMap = Maps:GetChildren()[math.random(1,#Maps:GetChildren())] -- Picks a random map
print(ChosenMap.Name.." Chosen")
TeamDistributor() -- calls Team Distributor Function
for RoundTimer = RoundTime, 0 , -1 do -- job of this script is to control the round
wait(1)
TimeLeft.Value = "Time Remaining: "..RoundTimer
for _, Player in pairs(game.Players:GetChildren()) do -- ignore this for now
local Char = Player.Character
end
end
end