I’m wondering if there are any imperfections in my code or things that I could improve on as I have a feeling this isn’t very optimized or there’s a better more efficient method. Any and all help would be appreciated!
local partPositions = {}
local partDistance = 2
local odds = 0
local evens = 0
for i = 0, playerCount - 1 do
if playerCount % 2 == 1 then
if i == 0 then
partPositions[i] = Vector3.new(0,0,0)
else
if i % 2 == 0 then
evens += 1
partPositions[i] = Vector3.new(evens * partDistance,0,0)
else
odds += 1
partPositions[i] = Vector3.new(odds * -partDistance,0,0)
end
end
else
if i == 0 then
partPositions[i] = Vector3.new(partDistance/2,0,0)
elseif i == 1 then
partPositions[i] = Vector3.new(-partDistance/2,0,0)
else
if i % 2 == 0 then
evens += 1
partPositions[i] = Vector3.new(evens * (partDistance + 1),0,0)
else
odds += 1
partPositions[i] = Vector3.new(odds * (-partDistance - 1),0,0)
end
end
end
end