I have written out the code but only the first code in the table works.
local code = {"2004", "6331"} --Only 2004 works as a code local text = script.Parent.Parent.CodeBar local val = script.Parent local plr = script.Parent.Parent.Parent.Parent.Parent print("ATM Loaded") script.Parent.MouseButton1Click:connect(function() for i,v in pairs(code) do if text.Text == v then print(plr.Name.." has entered the bank") script.Parent.Parent.Parent.PinCode.Visible = false script.Parent.Parent.Parent.Page1.Visible = true else text.Text = "Incorrect Pin!" wait(2) text.Text = "" end end end)
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.
local code = {"2004", "6331"} local text = script.Parent.Parent.CodeBar local val = script.Parent local plr = script.Parent.Parent.Parent.Parent.Parent print("ATM Loaded") script.Parent.MouseButton1Click:connect(function() for i,v in pairs(code) do if text.Text == v then print(plr.Name.." has entered the bank") script.Parent.Parent.Parent.PinCode.Visible = false script.Parent.Parent.Parent.Page1.Visible = true break --Found the code! Breaking the loop. end end if script.Parent.Parent.Parent.PinCode.Visible == true then --The code was never found in the loop. text.Text = "Incorrect Pin!" wait(2) text.Text = "" end end)