Roblox door script (press E to open)

A door that slides open when a player presses E and closes again after a few seconds — smooth, works on phones, and needs one script.

ScriptUpdated November 2, 2026

Where to put it

Script — Inside the door part (Workspace > Door > Script). It runs on the server, so players can't change what it does.

  1. Make the door an anchored Part.
  2. Insert a ProximityPrompt into the part, then a Script, and paste the code.

The script

Inside the door part (Workspace > Door > Script)
local TweenService = game:GetService("TweenService")

local door = script.Parent
local prompt = door:WaitForChild("ProximityPrompt")

local closed = door.CFrame
local open = closed * CFrame.new(door.Size.X, 0, 0) -- slide sideways by its own width
local info = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local busy = false

prompt.ActionText = "Open"

prompt.Triggered:Connect(function()
	if busy then return end
	busy = true
	prompt.Enabled = false
	TweenService:Create(door, info, { CFrame = open }):Play()
	task.wait(3)
	local closing = TweenService:Create(door, info, { CFrame = closed })
	closing:Play()
	closing.Completed:Wait()
	prompt.Enabled = true
	busy = false
end)

How it works

  • A ProximityPrompt shows “E Open” when players are close, and a tap button on phones.
  • TweenService moves the door smoothly between its closed and open position.
  • The prompt is disabled while the door moves, so spamming E can't break it.

Variations

VIP door for game pass owners

Only owners of a pass can open it. Replace PASS_ID with your pass ID.

local MarketplaceService = game:GetService("MarketplaceService")
local PASS_ID = 0

prompt.Triggered:Connect(function(player)
	local ok, owns = pcall(function()
		return MarketplaceService:UserOwnsGamePassAsync(player.UserId, PASS_ID)
	end)
	if not (ok and owns) then
		MarketplaceService:PromptGamePassPurchase(player, PASS_ID)
		return
	end
	-- open the door as above
end)

Hinged door that swings

Rotate the part around its edge instead of sliding it: replace the open line with this, and the rest of the script stays the same.

local hinge = closed * CFrame.new(-door.Size.X / 2, 0, 0)
local open = hinge * CFrame.Angles(0, math.rad(90), 0) * CFrame.new(door.Size.X / 2, 0, 0)

Common mistakes

  • Unanchored door: it falls over or gets pushed by players.
  • Tweening a Model directly — Tween parts, or move a Model with PivotTo.
  • Opening the door in a LocalScript: other players still see it closed and collide with it.

FAQ

How do I make a door open with E in Roblox?

Put a ProximityPrompt inside the door part and listen to its Triggered event in a server Script. E is the default key, and phones get a button automatically.

How do I make a door only VIPs can open?

In Triggered, check MarketplaceService:UserOwnsGamePassAsync for the player and only open it if they own your pass.

Keep reading