Below is a super-simple “click-to-open” door plus a smoother Tween version. Pick whichever matches your vibe. Copy/paste the code blocks exactly—no extra indentation needed.
🍔 QUICK SET-UP
In Roblox Studio, insert a Part (this will be the door).
Anchor it and turn CanCollide = true (so it blocks players).
In the Explorer:
• Right-click the Part ➜ Insert Object ➜ ClickDetector
• Right-click the Part again ➜ Insert Object ➜ Script (NOT LocalScript)
Paste one of the snippets below into that Script.
Hit Play!
──────────────────────────────
OPTION A – instant “pop open / pop shut”
──────────────────────────────
lua
-- Simple Door Script
local door = script.Parent
local clicker = door:WaitForChild("ClickDetector")
local CLOSED_POS = door.CFrame -- starting position
local OPEN_POS = door.CFrame * CFrame.new(0, 0, -4) -- move 4 studs backward
local isOpen = false
clicker.MouseClick:Connect(function()
isOpen = not isOpen
door.CFrame = isOpen and OPEN_POS or CLOSED_POS
door.CanCollide = not isOpen -- let players walk through
end)
──────────────────────────────
OPTION B – smooth slide using TweenService ✨
──────────────────────────────
lua
-- Smooth Tween Door Script
local door = script.Parent
local clicker = door:WaitForChild("ClickDetector")
local TweenService = game:GetService("TweenService")
local CLOSED_POS = door.CFrame
local OPEN_POS = door.CFrame * CFrame.new(0, 0, -4) -- slide 4 studs
local isOpen = false
local tweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local openTween = TweenService:Create(door, tweenInfo, {CFrame = OPEN_POS})
local closeTween = TweenService:Create(door, tweenInfo, {CFrame = CLOSED_POS})
clicker.MouseClick:Connect(function()
if isOpen then
closeTween:Play()
else
openTween:Play()
end
isOpen = not isOpen
door.CanCollide = not isOpen
end)
──────────────────────────────
FAQ / Tweaks
──────────────────────────────
• Change the direction: tweak the CFrame offset (x, y, z) in CFrame.new().
• Rotate instead of slide: replace the position with CFrame.Angles(math.rad(90),0,0) or combine rotation + translation.
• Want a proximity prompt instead of clicking? Replace the ClickDetector with a ProximityPrompt and wire its Triggered event to the same code block.
• Multiplayer safe? Yep—because it runs on the server (regular Script), all clients see the door state update.
Have fun building! If you need auto-closing, a keycard check, or anything fancy just let me know 💡