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
Sorry "Joined Match" and "Invalid Code" are supposed to swap places
string
try to print
code.Valueandscript.Parent.Parent.Parent.CodeInput.Textand their length, if they don't match then the strings are different.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.
Oh ok
How would I do that?
tostring in Lua,
tostring(5)returns 5 as a string.