How do I make only ONE of the TextLabels change in loop and not all of them?

Title says it all
code:

game.ReplicatedStorage.Events.PlayerJoin.OnClientEvent:Connect(function(player)
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("TextLabel") then
			if v.BeingUsed.Value == false then
				v.Text = "-"..player.Name
			end
		end
	end
end)

First of all: What is “script.Parent”?
And second: Why not just do:

if v.Name == "" -- [[The Textlabel's name.]]  then
end

Script.Parent is the frame in which the script itself and all of the image labels are contained in. Second. there are other objects which are not textlabels inside the frame. There are also multiple textlabel.

The "if v:IsA(“TextLabel)” part covers your second reason.

Because I’m trying to make a player list. Therefore all the textlabels will need to be changed at some point but not all of them at the same time just from one player joining.

In terms of a PlayerList, there is probably more efficient ways to go about this. Have you tried just cloning a new object when a player joins and editing the text label from there?

Either way, for your specific issue you could maybe try adding in a Value which checks if we’ve already changed one TextLabels value like below.

game.ReplicatedStorage.Events.PlayerJoin.OnClientEvent:Connect(function(player)
	local found = false
	
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("TextLabel") then
			if v.BeingUsed.Value == false then
				if found == false then
					found = true
					v.Text = "-"..player.Name
				end
			end
		end
	end
end)

Try changing the textlabel’s name to the players. Then all you got to do is:

script.Parent:FindFirstChild()--The players name

I would do that, but for my client, if theres no player for the slot he still wants the slot to be there but just say empty.

Your script worked. Though it may not be the most efficient , is it still reliable?

There are definitely more efficient ways to do that, but as for the shortest way whilst still following the guidelines with your script I believe it’s the quickest and easiest change you could make. In terms of reliability, I’d recommend making sure that once you’ve found a TextLabel, you set the v.BeingUsed's value to be true, that way once another player joins it won’t be overwritten.

It’s still being overwritten with 2 players.

Would you mind showing your updated script here?

game.ReplicatedStorage.Events.PlayerJoin.OnClientEvent:Connect(function(player)
	local found = false

	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("TextLabel") then
			if v.BeingUsed.Value == false then
				if found == false then
					found = true
					v.Text = "-"..player.Name
					v.BeingUsed.Value = true
				end
			end
		end
	end
end)

I checked the value in studio and it’s not being set to true for some reason

BeingUsed is a BoolValue stored inside of the TextLabel

Are you checking the PlayerGui, or are you checking the StarterGui? This will only effect the players PlayerGui.

so are you saying I should do game.Startergui instead of script.Parent?

No no, I mean what are you checking to see if the BoolValue has changed? Are you checking your PlayerGui, or are you checking the games StarterGui? I went ahead and tested the script and it seems to work fine if you check the PlayerGui.

game.ReplicatedStorage.Events.PlayerJoin.OnClientEvent:Connect(function(player)
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("TextLabel") then
			if v.BeingUsed.Value == false then
				v.Text = "-"..player.Name
				break --Break out of loop.
			end
		end
	end
end)

Add a break statement to the loop such that the loop is broken out of.