for Index, Value in pairs([locationsToValues]:GetChildren()) --Locations to the ValObjects. Make sure to use :GetChildren()
if not Value:IsA("StringValue") then continue end
-- Do what ever you need to with the values
end
Make sure to but :GetChildren() after you have defined the location. You could also use ipairs
Why would you need that exactly? Since if you are going to make changes separately at different times couldn’t you just define it yourself like this: local Value1 = [LocationOfValues].Value1. Or if you want to make different changes to each value then you can do something like this:
for Index, Value in pairs([locationsToValues]:GetChildren()) --Locations to the ValObjects. Make sure to use :GetChildren()
if not Value:IsA("StringValue") then continue end
if Value.Name == "Value1" then
-- Make the changes to Value1
elseif Value.Name == "Value2" then
-- Make the changes to Value2
end
-- Continue
end
Loops already loop through each child in this case, so it doesn’t need to get Value1 then go back then Value2 and go back, this would a very inefficient way.
I’d like to so it loops through the child once at a time doing:
game.Players[Value.Value]
Once It gets a child, It sets a image to their HeadShot using :GetUserThumbnailAsync, That’s why I get 1 child at a time to fill in 1 image then the 2’nd child to fill in the 2’nd image.
So what you want is to have it loop through all the player, and get there HeadShot thumbnail?
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
-- Settings for the Thumbnail
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
-- ImageLabel.Image = content
end
What this does is loop through each player and get there Headshot thumbnail, of course you have to define where you want it to go. So I know what your trying to say but the way you are imagining it is not how loops work. So what happens in a loop, what ever your looping so in this case the players it will iterate through each player and since each player is different it will always be a different Headshot Thumbnail, I think you are getting confused because you think it will make the same changes to each player, but that is only the case when you are working with constants, so things that will remain the same throughout. In this case the ThumbnailType and ThumbnailSize.
I hope this helps. I would recommend learning all the types of loops. Have a good day!
I thought those types of loops looped through all the players at once not indivigualy. To get a better understanding and for assurance this loops through each player in the service players one at a time?
Yeah there are many type of loops you can do, like earlier you did for i = 1, 4 do which would work if you did game:GetService("Players")[i] but there is another problem it will stop after 4 so what you could do is
local Players = game:GetService("Players")
for i = 1, #Players:GetPlayers() do -- '#' gets the length, so if there were 2 players the length would be 2
local UserId = Players[i].UserId
-- So on
end