local button = script.Parent
local click = button:FindFirstChild("ClickDetector")
local door = workspace:FindFirstChild("Door")
local isOpen = false
local moveDistance = 5
click.MouseClick:Connect(function(player)
if not door then
warn("Дверь не найдена!")
return
end
if isOpen then
door.Position = door.Position - Vector3.new(0, 0, moveDistance)
else
door.Position = door.Position + Vector3.new(0, 0, moveDistance)
end
isOpen = not isOpen
end)local TweenService = game:GetService("TweenService")
local button = script.Parent
local click = button.ClickDetector
local door = workspace.Door
local isOpen = false
local closedPos = door.Position
local openPos = door.Position + Vector3.new(0, 0, 5)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local function toggleDoor()
local goal = {}
if isOpen then
goal.Position = closedPos
else
goal.Position = openPos
end
local tween = TweenService:Create(door, tweenInfo, goal)
tween:Play()
isOpen = not isOpen
end
click.MouseClick:Connect(toggleDoor)local TweenService = game:GetService("TweenService")
local button = script.Parent
local pressedPos = button.Position - Vector3.new(0, 0.2, 0)
local defaultPos = button.Position
local function pressEffect()
local down = TweenService:Create(button, TweenInfo.new(0.1), {Position = pressedPos})
local up = TweenService:Create(button, TweenInfo.new(0.1), {Position = defaultPos})
down:Play()
down.Completed:Wait()
up:Play()
endlocal prompt = script.Parent.ProximityPrompt
local door = workspace.Door
local open = false
prompt.Triggered:Connect(function(player)
if open then
door.Position = door.Position - Vector3.new(0,0,5)
else
door.Position = door.Position + Vector3.new(0,0,5)
end
open = not open
end)prompt.Triggered:Connect(function(player)
local hasKey = player:FindFirstChild("Key")
if hasKey then
print("Дверь открыта")
else
warn("Нужен ключ!")
end
end)local sound = script.Parent:FindFirstChild("Sound")
if sound then
sound:Play()
end