it’s all in this script . there is only one script .
Try this to determine the problem and tell me the output:
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
print(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)
this is the whole script
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
Try this and tell me what output did you get:
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
print(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
Ok so is it working now? Because the variable CurrentCode is changing correctly
i haven’t press enter yet lol , i only screenshot the output . im gonna test later
Wait a second this is the correct one:
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
print(CurrentCode)
elseif button.Name == "Reset" then
CurrentCode = ""
Input.Text = CurrentCode
elseif button.Name == "Enter" then
if tostring(CurrentCode) == tostring(Code) then
CurrentCode = ""
Input.Text = "Success"
DoorOpenTween1:Play()
DoorOpenTween2:Play()
else
CurrentCode = ""
Input.Text = "Incorrect code"
end
end
end)
end
Please test it now. Copy and paste this into your script. If it worked it would be helpful if you would set this as solution.
it’s still not working , i’m now thinking one problem . Does “local” update variable?
Yes. If you define a variable again, the previous variable will be overwritten
Can you just say what’s not working? Is it like you typed the correct code and then it says incorrect code?
yes , i type in a correct code and it says incorrect code
Are you sure game.ReplicatedStorage.MainGameComponents.Values.Password.Value is assigned your correct code?
Yes , now i’m thinking something .
local CurrentCode = "" -- What is this lead to ? to it's name property ? to it's text ? or a value property ?
local Code = game.ReplicatedStorage.MainGameComponents.Values.Password.Value -- We know this is definitely a value property
Current code you assigned it a variable. It is an empty string. Can you just send me the game link and turn on copy so I can see what’s the problem? THis is getting too complicated even it’s just a simple problem tbh
i’m sorry , i can’t make my game editable to everyone . I was thinking another solution , maybe i can add another number value and add it to CurrentCode
Listen, go to game settings, and click on allow copying. It will not allow other players to EDIT it, but other layers can see the code and know what is wrong. But they can never change it because you only allowed copying, not editing. No offense but I’m just trying to be clear
What exactly is the problem?
Is it that you don’t know how to generate a random code? Or that the script does not read the code to be correct even if it is?
that’s not what i mean , i meant i dont want my game to be copied . I want a original game .
i know how to generate a random code , the problem is the code doesnt match the password even if it’s correct code . see my scripts up there