Increment variable inside of loop?
how would i increment var name of button and increment rectransform

 foreach (BasePlayer bplayer in BasePlayer.allPlayerList)
            {
               
                var player_button = elements.Add(new CuiButton
                {
                    Button =
                {
                    Command = "",
                    Color = "0.8 0.8 0.8 0.2"
                },

                    RectTransform =
                {
                    AnchorMin = $"0.01 0.9",
                    AnchorMax = $"0.15 0.99"
                },

                    Text =
                {
                    Text = bplayer.displayName,
                    FontSize = 14,
                    Align = TextAnchor.MiddleCenter
                }

                }, panel);
            }​
yes im looking to get even offline sleepers aswell

 int count = 0;
            foreach (BasePlayer bplayer in BasePlayer.allPlayerList)
            {
                var name = "player_Button" + count.ToString();
                 name = elements.Add(new CuiButton
                {
                    Button =
                {
                    Command = "",
                    Color = "0.8 0.8 0.8 0.2"
                },

                    RectTransform =
                {
                    AnchorMin = "0.01 0.9",
                    AnchorMax = "0.15 0.99"
                },

                    Text =
                {
                    Text = bplayer.displayName,
                    FontSize = 14,
                    Align = TextAnchor.MiddleCenter
                }

                }, panel);
                Puts(name); // just to check if names are different
                count++;
            }​

this seem to work thanks Wulf

going to try to do the same with

RectTransform
5d45358864483.png NooBlet
yes im looking to get even offline sleepers aswell

 int count = 0;
            foreach (BasePlayer bplayer in BasePlayer.allPlayerList)
            {
                var name = "player_Button" + count.ToString();
                 name = elements.Add(new CuiButton
                {
                    Button =
                {
                    Command = "",
                    Color = "0.8 0.8 0.8 0.2"
                },

                    RectTransform =
                {
                    AnchorMin = "0.01 0.9",
                    AnchorMax = "0.15 0.99"
                },

                    Text =
                {
                    Text = bplayer.displayName,
                    FontSize = 14,
                    Align = TextAnchor.MiddleCenter
                }

                }, panel);
                Puts(name); // just to check if names are different
                count++;
            }​

this seem to work thanks Wulf

going to try to do the same with

RectTransform

Instead of doing these complicated and hacky things, why don't just use for loop? It's faster and easier.

thanks @2CHEVSKII im a noob at c# but working on it i got the Foreach loop to work for now here is the code:

            double ancmin = 0.008163225;
            double ancmax = 0.09224492;
            double anczmin = 0.9030515;
            double anczmax = 0.951903325;

            foreach (BasePlayer bplayer in BasePlayer.allPlayerList)
            {
                
                var Button_name = elements.Add(new CuiButton
                {
                    Button =
                {
                    Command = $"DisplayName {bplayer.UserIDString} {bplayer.displayName}" ,
                    Color = "0 0 0 0.8"
                },

                    RectTransform =
                {
                    AnchorMin = $"{ancmin} {anczmin}",
                    AnchorMax = $"{ancmax} {anczmax}"
                },

                    Text =
                {
                    Text = bplayer.displayName,
                    FontSize = 14,
                    Align = TextAnchor.MiddleCenter
                }

                }, panel);

  
                if (ancmax >= 0.99)
                {
                    anczmin = anczmin - 0.055;
                    anczmax = anczmax - 0.055;
                    ancmin = 0.008163225 - 0.09;
                    ancmax = 0.09224492 - 0.09;
                }
                ancmin = ancmin + 0.09;
                ancmax = ancmax + 0.09;
            }​