Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I run through the list of players and set individual variables ?

Asked by
L3xie 0
5 years ago

How do I run through all the players in a server, and set 16 groups of variables with Players Names and User Ids without any repeating! I ask this because I will have a brick in the game with a SurfaceGui and this will make all the information easier to access.

Here's what I have for the beginning of my function.

function HGSpawn() for i = 1,#AllPlayers do if AllPlayers[i]:WaitForChild("Settings"):WaitForChild("HG").Value == false then AllPlayers[i]:WaitForChild("Settings"):WaitForChild("HG").Value = true if HGS.HG1.Toggle.Value == false then HGS.HG1.Toggle.Value = true HGS.HG1.Avatar.Value = AllPlayers[i].UserId HGS.HG1.Player.Value = AllPlayers[i].Name elseif HGS.HG1.Toggle.Value == true then HGS.HG2.Toggle.Value = true HGS.HG2.Avatar.Value = AllPlayers[i].UserId HGS.HG2.Player.Value = AllPlayers[i].Name

0
 Use codeblocks which are ~ so we can read your script, sigh mixgingengerina10 223 — 5y

1 answer

Log in to vote
0
Answered by
L3xie 0
5 years ago

Sorry, I'm new to scripting helpers... still trying to figure it out.

Heres the bad coding I did


function HGSpawn() for i = 1,#AllPlayers do 
if AllPlayers[i]:WaitForChild("Settings"):WaitForChild("HG").Value == false then AllPlayers[i]:WaitForChild("Settings"):WaitForChild("HG").Value = true 
if HGS.HG1.Toggle.Value == false then 
HGS.HG1.Toggle.Value = true 
HGS.HG1.Avatar.Value = AllPlayers[i].UserId
HGS.HG1.Player.Value = AllPlayers[i].Name 
elseif HGS.HG1.Toggle.Value == true then
HGS.HG2.Toggle.Value = true 
HGS.HG2.Avatar.Value = AllPlayers[i].UserId 
HGS.HG2.Player.Value = AllPlayers[i].Name
Ad

Answer this question