script.Parent.Touched:connect(function(p)
if p.Parent.Name == "MainKey" then
local door = script.Parent.Parent.Door1
local handle = script.Parent
local door2 = script.Parent.Parent.Door2
local handle2 = script.Parent.Parent.Handle2
door.Transparency = 1
door.CanCollide = false
handle.Transparency = 1
door2.Transparency = 0
door2.CanCollide = true
handle2.Transparency = 0
wait(1)
door.Transparency = 0
door.CanCollide = true
handle.Transparency = 0
door2.Transparency = 1
door2.CanCollide = false
handle2.Transparency = 1
else
game.StarterGui.DoorGUI.Instructions.Visible = true
end
end)
I've tried this
script.Parent.Touched:connect(function(p)
if p.Parent.Name == "MainKey" then
local door = script.Parent.Parent.Door1
local handle = script.Parent
local door2 = script.Parent.Parent.Door2
local handle2 = script.Parent.Parent.Handle2
door.Transparency = 1
door.CanCollide = false
handle.Transparency = 1
door2.Transparency = 0
door2.CanCollide = true
handle2.Transparency = 0
wait(1)
door.Transparency = 0
door.CanCollide = true
handle.Transparency = 0
door2.Transparency = 1
door2.CanCollide = false
handle2.Transparency = 1
elseif p.Parent.Name ~= "MainKey" then
game.StarterGui.DoorGUI.Instructions.Visible = true
end
end)
I've also tried this
local Instructionsss = game.StarterGui.DoorGUI.Instructions
script.Parent.Touched:connect(function(p)
if p.Parent.Name == "MainKey" then
local door = script.Parent.Parent.Door1
local handle = script.Parent
local door2 = script.Parent.Parent.Door2
local handle2 = script.Parent.Parent.Handle2
door.Transparency = 1
door.CanCollide = false
handle.Transparency = 1
door2.Transparency = 0
door2.CanCollide = true
handle2.Transparency = 0
wait(1)
door.Transparency = 0
door.CanCollide = true
handle.Transparency = 0
door2.Transparency = 1
door2.CanCollide = false
handle2.Transparency = 1
else
instructionsss.Visible = true
end
end)
I've also tried adding a repeat and until!

2 comments
Put your code inside a code block.
https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site