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

Why is only the first section of my script working?

I am creating a device that needs you to enter a password to access it. I have it set so each player has a different password. So it is the same lines of code, but each for different players. However, it currently doesn't work. It only allows the person who is at the top of the code to log in, anyone after the first person is denied access.

function onButtonClicked()
	
local Player = game.Players.LocalPlayer
	
	if script.Parent.Parent.Pass.Text == "BetaTesting" and Player.Name == "ConnorThomp" then
script.Parent.Parent.Parent:findFirstChild("LogIn").Visible = false
script.Parent.Parent.Parent:findFirstChild("HomePage").Visible = false
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").Visible = true
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").User.Text = ("ConnorThomp")
	
else script.Parent.Parent.Pass.Text = ("Incorrect Password")
	    	script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 0/255, 4/255)
wait (1)
script.Parent.Parent.Pass.Text = ("")
script.Parent.Parent.Pass.PlaceholderText = ("Password...")
script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 255/255, 255/255)
	end
	
	
	
	
	if script.Parent.Parent.Pass.Text == "BetaTesting" and Player.Name == "Vivificantern" then
script.Parent.Parent.Parent:findFirstChild("LogIn").Visible = false
script.Parent.Parent.Parent:findFirstChild("HomePage").Visible = false
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").Visible = true
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").User.Text = ("Vivificantern")
	
else script.Parent.Parent.Pass.Text = ("Incorrect Password")
	    	script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 0/255, 4/255)
wait (1)
script.Parent.Parent.Pass.Text = ("")
script.Parent.Parent.Pass.PlaceholderText = ("Password...")
script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 255/255, 255/255)
	end
	
	
	
	
	if script.Parent.Parent.Pass.Text == "BetaTesting" and Player.Name == "Vivificantern" then
script.Parent.Parent.Parent:findFirstChild("LogIn").Visible = false
script.Parent.Parent.Parent:findFirstChild("HomePage").Visible = false
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").Visible = true
script.Parent.Parent.Parent:findFirstChild("Page2").Visible = true
	
else script.Parent.Parent.Pass.Text = ("Incorrect Password")
	    	script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 0/255, 4/255)
wait (1)
script.Parent.Parent.Pass.Text = ("")
script.Parent.Parent.Pass.PlaceholderText = ("Password...")
script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 255/255, 255/255)
	end
	
end

script.Parent.MouseButton1Click:Connect(onButtonClicked)


1 answer

✓ Accepted answer

Could you not just have one else and put it at the bottom like so ?

function onButtonClicked()

local Player = game.Players.LocalPlayer

    if script.Parent.Parent.Pass.Text == "AlphaBravoBravoAlpha" and Player.Name == "ConnorThomp" then
script.Parent.Parent.Parent:findFirstChild("LogIn").Visible = false
script.Parent.Parent.Parent:findFirstChild("HomePage").Visible = false
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").Visible = true
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").User.Text = ("ConnorThomp")
end

    if script.Parent.Parent.Pass.Text == "BetaTesting" and Player.Name == "Vivificantern" then
script.Parent.Parent.Parent:findFirstChild("LogIn").Visible = false
script.Parent.Parent.Parent:findFirstChild("HomePage").Visible = false
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").Visible = true
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").User.Text = ("Vivificantern")
end

    if script.Parent.Parent.Pass.Text == "BetaTesting" and Player.Name == "Vivificantern" then
script.Parent.Parent.Parent:findFirstChild("LogIn").Visible = false
script.Parent.Parent.Parent:findFirstChild("HomePage").Visible = false
script.Parent.Parent.Parent:findFirstChild("AdministrationPage").Visible = true
script.Parent.Parent.Parent:findFirstChild("Page2").Visible = true

else script.Parent.Parent.Pass.Text = ("Incorrect Password")
            script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 0/255, 4/255)
wait (1)
script.Parent.Parent.Pass.Text = ("")
script.Parent.Parent.Pass.PlaceholderText = ("Password...")
script.Parent.Parent.Pass.TextColor3 = Color3.new(255/255, 255/255, 255/255)
    end

end

script.Parent.MouseButton1Click:Connect(onButtonClicked)

1 comment

0

That would be the smarter option. Thank you! :)

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