How can I do that with an if and elseif, if a value is the same, that the script is not executed?

Well, I want that if the Value of a StringValue is the same as the other 5 values ​​that there are, that it does not execute but the truth is I have no idea how to do it…

local button = script.Parent

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

local PlayerListMenu = script.Parent.Parent.Parent.Parent.Parent
local ChosenPlayers = PlayerListMenu:FindFirstChild("ChosenPlayers")
local IdPlayer = ChosenPlayers:FindFirstChild("IdPlayers")

local PlayerValue1 = ChosenPlayers:FindFirstChild("Player1")
local PlayerValue2 = ChosenPlayers:FindFirstChild("Player2")
local PlayerValue3 = ChosenPlayers:FindFirstChild("Player3")
local PlayerValue4 = ChosenPlayers:FindFirstChild("Player4")
local PlayerValue5 = ChosenPlayers:FindFirstChild("Player5")

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

button.MouseButton1Down:Connect(function()
	if (IDname.Value == PlayerValue1.Value) or (IDname.Value == PlayerValue2.Value) or (IDname.Value == PlayerValue3.Value) then
		if PlayerValue1.Value == "N/A" then
			Textbox1.TextBox.Text = IDDisplayName.Value
		elseif PlayerValue2.Value == "N/A" then
			TextBox2.TextBox.Text = IDDisplayName.Value
		elseif PlayerValue3.Value == "N/A" then
			TextBox3.TextBox.Text = IDDisplayName.Value
		elseif PlayerValue4.Value == "N/A" then
			TextBox4.TextBox.Text = IDDisplayName.Value
		elseif PlayerValue5.Value == "N/A" then
			TextBox5.TextBox.Text = IDDisplayName.Value
		end
	end
end)

Simply do this via and like this:

if PlayerValue1.Value == "N/A" and PlayerValue2.Value == "N/A" then

I think this is what you are trying to do

local button = script.Parent

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

local PlayerListMenu = script.Parent.Parent.Parent.Parent.Parent
local ChosenPlayers = PlayerListMenu:FindFirstChild("ChosenPlayers")
local IdPlayer = ChosenPlayers:FindFirstChild("IdPlayers")

local PlayerValue1 = ChosenPlayers:FindFirstChild("Player1")
local PlayerValue2 = ChosenPlayers:FindFirstChild("Player2")
local PlayerValue3 = ChosenPlayers:FindFirstChild("Player3")
local PlayerValue4 = ChosenPlayers:FindFirstChild("Player4")
local PlayerValue5 = ChosenPlayers:FindFirstChild("Player5")

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

local TableOfText = {
	PlayerValue1 = ChosenPlayers:FindFirstChild("Player1");
	PlayerValue2 = ChosenPlayers:FindFirstChild("Player2");
	PlayerValue3 = ChosenPlayers:FindFirstChild("Player3");
	PlayerValue4 = ChosenPlayers:FindFirstChild("Player4");
	PlayerValue5 = ChosenPlayers:FindFirstChild("Player5");
}


local TableOfText2 = {
	Textbox1 =  IdPlayer:FindFirstChild("TextBox1");
	TextBox2 =  IdPlayer:FindFirstChild("TextBox2");
	TextBox3 =  IdPlayer:FindFirstChild("TextBox3");
	TextBox4 =  IdPlayer:FindFirstChild("TextBox4");
	TextBox5 =  IdPlayer:FindFirstChild("TextBox5");

}



button.MouseButton1Down:Connect(function()
	if (IDname.Value == PlayerValue1.Value) or (IDname.Value == PlayerValue2.Value) or (IDname.Value == PlayerValue3.Value) then
		for i,v in pairs(TableOfText) do
			if v.IDname.Value == "N/A" then --if the string value is N/A then
				
				
			else --if not then
				
				for i, v in pairs(TableOfText2) do
					v.TextBox.Text = IDDisplayName.Value
				end
				
				print("The value is not N/A")
			end
		end
	end

end)
1 Like