Secret Doorway (Key)

Secret Doorway

Where to put this script

In a script in an invisible part in front of the wall or door

Scripts

local part = script.Parent

local wall = game.Workspace.Wall

local canOpen = true


local function lift(otherPart)

local partParent = otherPart.Parent

local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")

if humanoid and canOpen then

local player = game.Workspace:FindFirstChild(partParent.Name)

if player then

if player:FindFirstChild('Key') then

canOpen = false

wall.Transparency = 1

wall.CanCollide = false

local key = player:FindFirstChild('Key')

key.Parent = game.Workspace

key.Handle.Position = Vector3.new(math.random(x1,x2),5,math.random(z1,z2))

wait(2)

wall.Transparency = 0

wall.CanCollide = true

canOpen = true

end

end

end

end


part.Touched:Connect(lift)