Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

3 comments

0

You should really use GetPropertyChangedSignal() here. It is extremely useful for this situation.

0

^^

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.

1 answer

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)

1 comment

0

That doesn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.