Get all players List<string>

I personally have NEVER seen someone with a ", " in their name. And I’ve been playing on this account since 2018

you never know ¯_(ツ)_/¯

Your almost correct! This is from a old youtube video of mine this is the correct way.

1 Like

Like @Ardenis said, almost correct

  1. You dont need to calculate this on update, you only need to calculate this when you need to call it (else your wasting CPU)
  2. List Add instead of setting the variable to itself and List Concat/List Union the player name (I already see you corrected this one)
  3. The For Each method works regardless of how many players are in the room or what their display names are. The To String + String Split method will fail if any player has , in their name, or the combination of everyone’s display names + the separator characters is greater than 512, because then anyone elses name will be cut short

The circuit is this simple, 6 chips at worst, 5 chips at best (Assuming you re-use the empty List Create to reset the variable instead of using List Clear). If you use a function, then it will be 9 chips to create the function, and 1 chip every time you want to call it


*The arrows in this image are just supposed to show that List Clear is interchangeable with setting the list variable to an empty List Create, depends on what you prefer

1 Like

ehhh potato potahto

mb for some reason when i do stuff with lists i always make like the same mistake of setting the variable twice idk why

Does the For Each chip take up a lot of CPU? I dunno why but I might have gotten this false impression that it uses a lot of cpu

Its not that the chip itself uses alot of CPU, its that, for each loop (so each For iteration, or For Each item in a list), it has to run the Loop circuit again

This means the amount of CPU a For Each uses is based off of:
A. How many iterations you are doing
B. The raw cost of your loop

This is why you never want to put expensive logic in a for loop unless its a custom, limited/staggered for loop, which still runs the loop really fast, but not instantly, so you could say “For numbers 0 to 1,000”, but say “After every 25 iterations, wait 1 frame for CPU to clear”, so instead of doing 1,000 loops instantly, you would do 1,000 loops over the course of around 0.667 seconds

Thanks so much!