I’m currently working on a code system and it works well, but you can just leave and join back to use the code again.
Heres my code so far:
local textbox = script.Parent.TextBox
local Codes = {
Code1 = { "RELEASE", false},
}
local function onButtonPress()
textbox.FocusLost:Connect(function(Enter)
for i, v in pairs(Codes) do
if Enter then
if Codes[i][2] == false and textbox.Text == Codes[i][1] then
print(i)
Codes[i][2] = true
textbox.Text = "Code Redeemed!"
wait(1)
textbox.Text = ""
else
if Codes[i][2] == true and textbox.Text == Codes[i][1] then
textbox.Text = "Code Already Redeemed!"
wait(1)
textbox.Text = ""
else
if textbox.Text ~= Codes[i][1] then
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)