should i keep my if statements in a single line?
doing this does reduce the amount of lines of code drastically, but for the trade off of being harder to understand what the code does, and the length is quite long
and for my if statements compares conditionals, i basically made the condition to the exact opposite
like > would be <= and then return
here’s my code
local function addPlayer(Player)
local addPlayer = table.find(partyPlayersList,Player)
if addPlayer or #partyPlayersList >= maxPlayers then return end --if player not in part or if party is less than max players
table.insert(partyPlayersList,Player)
updatePlayer()
if #partyPlayersList < minPlayers or timerConnect.Connected then return end --if party is greater or equal to min players or the timer isn't running
debounce = time() timerConnect = RunService.Heartbeat:Connect(timer)
end
local function removePlayer(Player)
local removePlayer = table.find(partyPlayersList, Player)
table.remove(partyPlayersList, removePlayer)
updatePlayer()
if #partyPlayersList >= minPlayers then return end --if party is less than min players
timerConnect:Disconnect()
teleporter:SetAttribute("Time", timerValue)
updateTimer()
end
here my code originally before i changed it
local function addPlayer(Player)
local addPlayer = table.find(partyPlayersList,Player)
if addPlayer then return end
if #partyPlayersList < maxPlayers then
table.insert(partyPlayersList,Player)
updatePlayer()
if #partyPlayersList >= minPlayers then
if timerConnect.Connected then return end
debounce = time() timerConnect = RunService.Heartbeat:Connect(timer)
end
end
end
local function removePlayer(Player)
local removePlayer = table.find(partyPlayersList, Player)
if not removePlayer then return end
table.remove(partyPlayersList, removePlayer)
updatePlayer()
if #partyPlayersList < minPlayers then
timerConnect:Disconnect()
teleporter:SetAttribute("Time", timerValue)
updateTimer()
end
end
does it event matter? or not?