Problem with the elseif

Well, basically I have a problem with the elseif of PlayerIdValue3.Value == "N / A" then and the ones below that elseif are not executed either and I don’t see the problem, I already check and if the values ​​are well connected

local Button = script.Parent
local PlayerChoosenValue = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("ChosenPlayers")
local TextPlayersSelection = PlayerChoosenValue:FindFirstChild("Players"):FindFirstChild("ScrollingFrame")

local IdDisplayName = script.Parent:FindFirstChild("IdDisplayName")
local RealName = script.Parent:FindFirstChild("IdName")

local TextBox1 = TextPlayersSelection:FindFirstChild("TextBox1")
local TextBox2 = TextPlayersSelection:FindFirstChild("TextBox2")
local TextBox3 = TextPlayersSelection:FindFirstChild("TextBox3")
local TextBox4 = TextPlayersSelection:FindFirstChild("TextBox4")
local TextBox5 = TextPlayersSelection:FindFirstChild("TextBox5")

local PlayerIdValue1 = PlayerChoosenValue:FindFirstChild("Player1")
local PlayerIdValue2 = PlayerChoosenValue:FindFirstChild("Player2")
local PlayerIdValue3 = PlayerChoosenValue:FindFirstChild("Player3")
local PlayerIdValue4 = PlayerChoosenValue:FindFirstChild("Player4")
local PlayerIdValue5 = PlayerChoosenValue:FindFirstChild("Player5")

Button.MouseButton1Down:Connect(function()
if PlayerIdValue1.Value == "N/A" then
TextBox1.TextBox.Text = IdDisplayName.Value
elseif PlayerIdValue2.Value == "N/A" then
TextBox2.TextBox.Text = IdDisplayName.Value
elseif PlayerIdValue3.Value == "N/A" then
TextBox3.TextBox.Text = IdDisplayName.Value
elseif PlayerIdValue4.Value == "N/A" then
TextBox4.TextBox.Text = IdDisplayName.Value
elseif PlayerIdValue5.Value == "N/A" then
TextBox5.TextBox.Text = IdDisplayName.Value
end
end)

‘elseif’ will run if its conditions are met and will stop the if statement there if it ran.

It is well connected and if it meets the conditions but does not activate

Pcall it, pcalls usually work…

local Button = script.Parent
local PlayerChoosenValue = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("ChosenPlayers")
local TextPlayersSelection = PlayerChoosenValue:FindFirstChild("Players"):FindFirstChild("ScrollingFrame")

local IdDisplayName = script.Parent:FindFirstChild("IdDisplayName")
local RealName = script.Parent:FindFirstChild("IdName")

Button.MouseButton1Down:Connect(function()
    for i = 1, 5, 1 do
        local TextBox = TextPlayersSelection:FindFirstChild("TextBox"..i)
        local PlayerIdValue = PlayerChoosenValue:FindFirstChild("Player"..i)
        if PlayerIdValue.Value == "N/A" then
            TextBox.TextBox.Text = IdDisplayName.Value
        end
    end
end)

this should work

Wouldn’t this also work? It should give an error I guess?

Button.MouseButton1Down:Connect(function()
	local s, e = pcall(function()
		if PlayerIdValue1.Value == "N/A" then
			TextBox1.TextBox.Text = IdDisplayName.Value
		elseif PlayerIdValue2.Value == "N/A" then
			TextBox2.TextBox.Text = IdDisplayName.Value
		elseif PlayerIdValue3.Value == "N/A" then
			TextBox3.TextBox.Text = IdDisplayName.Value
		elseif PlayerIdValue4.Value == "N/A" then
			TextBox4.TextBox.Text = IdDisplayName.Value
		elseif PlayerIdValue5.Value == "N/A" then
			TextBox5.TextBox.Text = IdDisplayName.Value
		end
	end)
	if not s then game:GetService("TestService"):Error(e) end
end)

this code would only error if IdDisplayName.Value isn’t a string

EDIT:

please use error(), why use TestService if you don’t have to

whoops ur right, my bad lol. 3030303030330