Alternatives to "while true do" in my script?

I’m sorry, I have no clue. You might be able to look it up on google though.

In this case while true is okay to use. It may actually be slower to invoke the disconnect method. Your prior method appeared to be better performance-wise.

in the line:

local nextPart = parts[i - 1] or parts[#parts]

change it to:

if i - 1 < 1 then return end
local nextPart = parts[i - 1]

The script I sent is more efficient and less resource-intensive.