Pass Code Not Working

  1. What do you want to achieve?

    so i was making a random password door

  2. What is the issue?

    i don’t know why but my randomly generated passcode doesn’t work for my pass door ,
    see the script below .

    Scripts Below

local Door1 = script.Parent.DoorPart1
local Door2 = script.Parent.DoorPart2

local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1.8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local DoorOpenPosition1 = script.Parent.OpenPosition1
local DoorOpenPosition2 = script.Parent.OpenPosition2

local DoorClosePosition1 = script.Parent.ClosedPosition1
local DoorClosePosition2 = script.Parent.ClosedPosition2

local DoorOpenTween1 = TweenService:Create(Door1, Info,{CFrame = DoorOpenPosition1.CFrame})
local DoorOpenTween2 = TweenService:Create(Door2, Info,{CFrame = DoorOpenPosition2.CFrame})

local DoorCloseTween1 = TweenService:Create(Door1, Info, {CFrame = DoorClosePosition1.CFrame})
local DoorCloseTween2 = TweenService:Create(Door2, Info, {CFrame = DoorClosePosition2.CFrame})

local Input = script.Parent.KeypadBase.KeypadGui.InputtedCode
local Button = script.Parent.KeypadBase.KeypadGui.ButtonsBG

local Code = game.ReplicatedStorage.MainGameComponents.Values.Password.Value
local CurrentCode = ""

Input.Text = CurrentCode

for i, button in pairs(Button:GetChildren()) do


	button.MouseButton1Click:Connect(function()

		if tonumber(button.Name) then

			CurrentCode = CurrentCode .. button.Name
			Input.Text = CurrentCode


		elseif button.Name == "Reset" then

			CurrentCode = ""
			Input.Text = CurrentCode


		elseif button.Name == "Enter" then


			if CurrentCode == Code then

				CurrentCode = ""

				Input.Text = "Success"
				DoorOpenTween1:Play()
				DoorOpenTween2:Play()

			else

				CurrentCode = ""
				Input.Text = "Incorrect code"
			end
		end
	end)
end




--Old Scripts

--script.Parent.DoorPart1.Touched:Connect(function()
	--DoorOpenTween1:Play()
	--DoorOpenTween2:Play()
--end)


If i can do like that , then i can’t make a randomly generated passcode door … somebody please help me

Can you show me all the scripts? Because you only showed me two lines and I can’t know what’s wrong

im sorry but i close my studio …

I know your problem now. Try this:

local code = tostring(game.ReplicatedStorage.NumValue.Value)
1 Like

Hello. This topic is not understandable. Please provide more scripts and ideas. You also need to explain more into what your trying to do or show the community. Thankyou.

This might work:

local code = tostring(game.ReplicatedStorage.NumValue.Value)

If it worked it would be helpful if you would set this as solution. :slight_smile:

i edited my post just now , the whole script is up there

1 Like

Did you try to do this?

local code = tostring(game.ReplicatedStorage.MainGameComponents.Values.Password.Value)

If it worked it would be helpful if you would set this as solution. :slight_smile:

im gonna try it now , thanks for the help btw

Did it work? If it worked it would be helpful if you would set this as solution. :slight_smile:

the script is not working , there is no error as well

Try this then:

local Code = tostring(game.ReplicatedStorage.MainGameComponents.Values.Password.Value)

this is the script i’m using just now

I saw that you didn’t assign the variable CurrentCode to anything. Try to change that. Or show me the code where you assigned it to anything,

but if I change that , the script will not work . the current code is suppose to be blank at first .
(also it’s not only a gui , it’s a part with surface gui)

Yes but when and where did you assign it anything? Because if it stays empty throughout the entire game, well, it wouldn’t work because it would never equal to the code.

on the part there is surface gui , inside there is 11 button which is number 1 to 9 , enter and reset button . on top there is a text label that is connect to the current code . (current code will change when you press the 1 to 9 button , press reset to reset back to " " .)

Is it in the same script? If it is in a different script, it would not work. If you don’t know how to merge the two scripts, I will help you.

u mean the door script and generate password script?

I mean the script that you change the variable CurrentCode. Show me the script where you changed the variable CurrentCode.