Stores and checks if user already inputed password (Roblox Lua)

Viewed 22

So, I'm trying to make it so, every player has to enter a password to play the game. I was trying to make it a more user-friendly experience by making it so it remembers if the player already inputed it and if so it doesn't ask for the password. I have been trying to get this to work for hours with no luck. Any ideas?

local subbtn = script.Parent
local DataStoreService = game:GetService("DataStoreService")
local goldStore = DataStoreService:GetDataStore("enteredpassword")
local player = game.Players.LocalPlayer
local frame = script.Parent.Parent
local passbox = script.Parent.Parent.TextBox
local password = "Your Password"
enteredpassword = {}

-- Read data store key

goldStore:GetAsync(enteredpassword)


if enteredpassword[player.Name] == nil then
    frame.Visible = true
end
subbtn.MouseButton1Click:Connect(function()
    if passbox.Text == password then
        subbtn.Text = "Password Correct!"
        wait(1)
        frame.Visible = false
        table.insert(enteredpassword, player.Name)
        goldStore:SetAsync(enteredpassword)

        
    else
        subbtn.Text = "Password Incorrect!"
        passbox.Text = ""
        wait(2)
        subbtn.Text = "submit"
        
    end
end)
0 Answers
Related