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!