Secret Doorway (Touch)
Secret Doorway
Where to put this Script
In a script in the part that will be touched to open the wall or door
Script
Make Wall Go Up
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
canOpen = false
wall.Position = wall.Position + Vector3.new(0,12,0)
wait(3)
wall.Position = wall.Position + Vector3.new(0,-12,0)
canOpen = true
end
end
part.Touched:Connect(lift)
Make Wall Go Up (Smooth Motion)
local trigger = script.Parent
local wall = game.Workspace.Wall --var for rising wall
local sound = game.Workspace['Castle Gate'] --var for sound
local canOpen = true
local openDistance = 12 --height the door goes up
local steps = 100 --number of steps door take (more = smoother)
local stepSize = openDistance / steps --distance for each step
local function lift(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA('Humanoid')
if humanoid and canOpen then
canOpen = false
sound:Play() --plays sound
trigger.BrickColor = BrickColor.new('Lime green') --changes color
--opens door
for i = 1, steps do
wall.Position = wall.Position + Vector3.new(0,stepSize,0)
wait()
end
--wait time before close
wait(3)
--closes door
for i = 1, steps do
wall.Position = wall.Position - Vector3.new(0,stepSize,0)
wait()
end
trigger.BrickColor = BrickColor.new('Really red') --changes color
canOpen = true
end
end
trigger.Touched:Connect(lift)
Make Wall Disappear
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
canOpen = false
wall.Transparency = 1
wall.CanCollide = false
wait(3)
wall.Transparency = 0
wall.CanCollide = true
canOpen = true
end
end
part.Touched:Connect(lift)