I’m working on a code system and only one code works?
Heres my code:
local textbox = script.Parent.TextBox
local Codes = {
[1] = { "RELEASE", Claimed = false},
[2] = {"DtayDa1", Claimed = false}
}
local function onButtonPress()
textbox.FocusLost:Connect(function(Enter)
for i = 1,2 do
print(i)
if Enter then
if Codes[i].Claimed == false and textbox.Text == Codes[i][1] then
print(textbox.Text)
Codes[i].Claimed = true
textbox.Text = "Code Redeemed!"
wait(1)
textbox.Text = ""
else
if Codes[i].Claimed == true and textbox.Text == Codes[i][1] then
print(textbox.Text)
textbox.Text = "Code Already Redeemed!"
wait(1)
textbox.Text = ""
else
if textbox.Text ~= Codes[i][1] then
print(textbox.Text)
textbox.Text = "Invalid Code!"
wait(1)
textbox.Text = ""
end
end
end
end
end
end)
end
script.Parent.Parent.Left.Content.Codes.MouseButton1Click:Connect(onButtonPress)
script.Parent.Parent.Left.Content.Codes.TouchTap:Connect(onButtonPress)
Any help is appreciated!