Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My login script says I am inputting the wrong password when it's right?

Asked by 4 years ago

So, I basically created a pretty simple GUI script that forces you to input a given password to be given access to the game.

Now, for some reason, whenever I input the correct password, it still says it is wrong.

Help?

local maxTries = 3
local currentAttempts = 0
local pass = "DEV@2019"
local banMessage = "Attempting to access a password-protected game"
local button = script.Parent
local passBox = game.StarterGui.ScreenGui.PassTextBox

button.MouseButton1Click:Connect(function()
    if currentAttempts == 3 and maxTries == 3 then
        game.Players.LocalPlayer:Kick(banMessage)

    else
        if passBox.Text == pass then
            button.Text = "Game loading..."  
            wait(1)
            game.StarterGui.ScreenGui:Destroy()
        else
            if passBox.Text ~= pass then
                button.Text = "Wrong password"
            end
            wait(1)
            currentAttempts = currentAttempts + 1
            button.Text = "Submit"

        end
    end
end)
0
You should really use GetPropertyChangedSignal() here. It is extremely useful for this situation. DeceptiveCaster 3761 — 4y
0
^^ littlemike1234_PUMAS 117 — 4y
0
I made something like this not too long ago, but instead of making the password a variable in the script I made it a string value inside of the part. MustangHeart 67 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Try this.. All I did was move the text variable into the click function

local maxTries = 3
local currentAttempts = 0
local pass = "DEV@2019"
local banMessage = "Attempting to access a password-protected game"
local button = script.Parent

button.MouseButton1Click:Connect(function()
    local passBox = game.StarterGui.ScreenGui.PassTextBox

    if currentAttempts == 3 and maxTries == 3 then
        game.Players.LocalPlayer:Kick(banMessage)

    else
        if passBox.Text == pass then
            button.Text = "Game loading..."  
            wait(1)
            game.StarterGui.ScreenGui:Destroy()
        else
            if passBox.Text ~= pass then
                button.Text = "Wrong password"
            end
            wait(1)
            currentAttempts = currentAttempts + 1
            button.Text = "Submit"

        end
    end
end)

0
That doesn't work. DeceptiveCaster 3761 — 4y
Ad

Answer this question