I see the error in your script. When you put the code as 6331, it will first check if it says "2004". After seeing it is false, it will set the text to blank two seconds later. After looping, it will then check if the code says "6331", but since you changed the text to become blank, that too will return as false.
Here is a modified version for your script to get it to work.
01 | local code = { "2004" , "6331" } |
02 | local text = script.Parent.Parent.CodeBar |
03 | local val = script.Parent |
04 | local plr = script.Parent.Parent.Parent.Parent.Parent |
08 | script.Parent.MouseButton 1 Click:connect( function () |
09 | for i,v in pairs (code) do |
10 | if text.Text = = v then |
11 | print (plr.Name.. " has entered the bank" ) |
12 | script.Parent.Parent.Parent.PinCode.Visible = false |
13 | script.Parent.Parent.Parent.Page 1. Visible = true |
17 | if script.Parent.Parent.Parent.PinCode.Visible = = true then |
18 | text.Text = "Incorrect Pin!" |