So I'm trying to make it so the player types in a match code and when they click join if a match has that code it prints "Joined Match". Whenever the script is like this it prints "Joined Match!":

script.Parent.MouseButton1Click:Connect(function()

	
	for _,v in pairs(game.Workspace:GetChildren()) do
		if v.ClassName == "Folder" then
			for _,matches in pairs(v:GetChildren()) do
				if matches.ClassName == "Folder" then
					for _,code in pairs(matches:GetChildren())do
						if code.Name== "MatchCode" then
							if code.Value == "1111" then --1111 is the test code I used
								print("Invalid Code")
							else
								print("Joined Match!")
							end
						
							
						end
					end
				end
				end
		end
	end
end)

But when the script is like this it prints "Invalid Code":

script.Parent.MouseButton1Click:Connect(function()

	
	for _,v in pairs(game.Workspace:GetChildren()) do
		if v.ClassName == "Folder" then
			for _,matches in pairs(v:GetChildren()) do
				if matches.ClassName == "Folder" then
					for _,code in pairs(matches:GetChildren())do
						if code.Name== "MatchCode" then
							if code.Value == script.Parent.Parent.Parent.CodeInput.Text then --CodeInput is the textbox where players put in the code (I still used the code 1111)
								print("Invalid Code")
							else
								print("Joined Match!")
							end
						
							
						end
					end
				end
				end
		end
	end
end)

Someone Please help!

7 comments

0

Sorry "Joined Match" and "Invalid Code" are supposed to swap places

0

string

0

try to print code.Value and script.Parent.Parent.Parent.CodeInput.Text and their length, if they don't match then the strings are different.

0

You may also find, along with what CoolGuy16T said, that you're comparing a number/integer with a string value, regardless of whether they are equal in their raw values. As the value in the text box will be a string, you should convert it to an integer first.

0

Oh ok

0

How would I do that?

0

tostring in Lua, tostring(5) returns 5 as a string.