I have a code door but it only works in studio not the actual game.
In the actual game, it doesn’t let me click the buttons.
Studio footage:
https://i.gyazo.com/374d121043d0ccc1a93d524fa69b4f82.mp4
Roblox footage:
https://i.gyazo.com/7df068a0e709f12c9a2662ead84a44de.mp4
Door code:
local airlockDoor = script.Parent.AirlockDoor
local sound = script.Parent.AirlockDoor.DoorMain.DoorHinge.Sound
local buttonSound = script.Parent.Frame.KeypadSound.Sound
local configs = script.Parent.Configurations
local doorOpen = false
local code = math.random(1,1000)
local nums = {"1","2","3","4","5","6","7","8","9","0"}
local input = {}
local display = script.Parent.Display.SurfaceGui.TextBox
game:GetService("Workspace").CodePart.SurfaceGui.TextLabel.Text = code
print(code)
buttonSound.SoundId = configs.ButtonSound.Value
function closeAirlock()
for i = 1, 80 do
airlockDoor.DoorTop:SetPrimaryPartCFrame(airlockDoor.DoorTop.PrimaryPart.CFrame * CFrame.new(0,-0.05,0))
airlockDoor.DoorBottom:SetPrimaryPartCFrame(airlockDoor.DoorBottom.PrimaryPart.CFrame * CFrame.new(0,0.05,0))
airlockDoor.DoorMain:SetPrimaryPartCFrame(airlockDoor.DoorMain.PrimaryPart.CFrame * CFrame.new(-0.05,0,0))
wait()
end
sound.SoundId = configs.CloseSound.Value
sound:Play()
for i = 1, 60 do
airlockDoor.DoorTop:SetPrimaryPartCFrame(airlockDoor.DoorTop.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(1.5)))
airlockDoor.DoorBottom:SetPrimaryPartCFrame(airlockDoor.DoorBottom.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(-1.5)))
wait()
end
doorOpen = false
end
function openAirlock()
doorOpen = true
sound.SoundId = configs.OpenSound.Value
sound:Play()
for i = 1, 60 do
airlockDoor.DoorTop:SetPrimaryPartCFrame(airlockDoor.DoorTop.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(-1.5)))
airlockDoor.DoorBottom:SetPrimaryPartCFrame(airlockDoor.DoorBottom.PrimaryPart.CFrame * CFrame.Angles(0,0,math.rad(1.5)))
wait()
end
for i = 1, 80 do
airlockDoor.DoorTop:SetPrimaryPartCFrame(airlockDoor.DoorTop.PrimaryPart.CFrame * CFrame.new(0,0.05,0))
airlockDoor.DoorBottom:SetPrimaryPartCFrame(airlockDoor.DoorBottom.PrimaryPart.CFrame * CFrame.new(0,-0.05,0))
airlockDoor.DoorMain:SetPrimaryPartCFrame(airlockDoor.DoorMain.PrimaryPart.CFrame * CFrame.new(0.05,0,0))
wait()
end
wait(configs.OpenTime.Value)
closeAirlock()
end
function updateScreen()
local currentDisplay = table.concat(input)
if #input < string.len(code) then
repeat
display.Text = currentDisplay .. "-"
currentDisplay = display.Text
wait()
until string.len(display.Text) == string.len(code)
else
display.Text = currentDisplay
end
end
updateScreen()
for i, v in pairs(script.Parent.KeyPad:GetChildren()) do
v.ClickDetector.MouseClick:Connect(function()
if v.Name == "Enter" and doorOpen == false then
buttonSound:Play()
if tonumber(table.concat(input)) == code then
display.Text = "CORRECT"
input = {}
spawn(openAirlock)
wait(2)
display.Text = ""
updateScreen()
else
display.Text = "WRONG"
input = {}
wait(2)
display.Text = ""
updateScreen()
end
elseif v.Name == "Enter" and doorOpen == true then
buttonSound:Play()
display.Text = "WAIT"
input = {}
wait(2)
display.Text = ""
updateScreen()
elseif v.Name == "Exit" and doorOpen == false then
buttonSound:Play()
openAirlock()
elseif v.Name == "Delete" then
buttonSound:Play()
input = {}
updateScreen()
--else
--for i = 1, 10 do
elseif tonumber(v.Name) then
buttonSound:Play()
if #input >= string.len(code) then
table.remove(input, 1)
end
table.insert(input, v.Name)
updateScreen()
--end
--end
end
end)
end