Roblox Studio tutorial · Beginner

How to Make a Door in Roblox Studio (Press E to Open)

Here is how to make a door in Roblox Studio that swings or slides open when a player presses E, waits a few seconds and closes by itself. One short script, explained line by line.

  • Press E to open with a ProximityPrompt
  • Smooth hinge or slide animation with TweenService
  • Closes by itself, with a debounce against spam

Step by step

  1. Build the door part

    Insert a Part and name it Door. In Properties set Size to 4, 7, 0.5 so the width runs along X. Place it in your doorway and turn on Anchored, otherwise physics fights the animation and the door falls over.

  2. Add a ProximityPrompt

    In the Explorer, hover over Door, click the plus button and insert a ProximityPrompt. Keep its name as ProximityPrompt. Set ActionText to Open and ObjectText to Door. The default key is already E.

  3. Add the Script

    Hover over Door again and insert a Script (not a LocalScript). Delete the print line and paste the door script below. The script must sit directly inside the Door part because it uses script.Parent to find the door.

  4. Choose swing or slide

    Leave SLIDE = false for a hinged door that swings 90 degrees around its left edge. Set SLIDE = true for a sliding door that moves sideways by its own width. Change OPEN_TIME and STAY_OPEN to adjust the timing.

  5. Playtest the door

    Press Play (F5), walk up to the door and press E. The door should open smoothly, wait three seconds and close again. Spam E while it moves: thanks to the debounce, nothing breaks. Check the Output window if nothing happens.

  6. Fix the swing direction

    If the door swings into the room or into the wall, change math.rad(90) to math.rad(-90). If it turns around the wrong edge, change -door.Size.X / 2 to door.Size.X / 2 so the hinge moves to the other side.

The script

Script — put inside the Door part (Script)
-- Script inside the Door part (the Door must be Anchored)
local TweenService = game:GetService("TweenService")

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

local OPEN_TIME = 0.6   -- seconds the door takes to open or close
local STAY_OPEN = 3     -- seconds before the door closes by itself
local SLIDE = false     -- true = slide sideways, false = swing on a hinge

-- Remember where the closed door is, then work out the open position
local closedCFrame = door.CFrame
local openCFrame
if SLIDE then
	-- move the door sideways by its own width
	openCFrame = closedCFrame * CFrame.new(door.Size.X, 0, 0)
else
	-- turn 90 degrees around the door's left edge (the hinge)
	local hinge = CFrame.new(-door.Size.X / 2, 0, 0)
	openCFrame = closedCFrame * hinge * CFrame.Angles(0, math.rad(90), 0) * hinge:Inverse()
end

-- A tween smoothly animates a property from its current value to a goal
local tweenInfo = TweenInfo.new(OPEN_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local openTween = TweenService:Create(door, tweenInfo, { CFrame = openCFrame })
local closeTween = TweenService:Create(door, tweenInfo, { CFrame = closedCFrame })

local isBusy = false -- debounce: ignore presses while the door is moving

prompt.Triggered:Connect(function()
	if isBusy then
		return
	end
	isBusy = true
	prompt.Enabled = false -- hide "Press E" while the door is open

	openTween:Play()
	openTween.Completed:Wait()
	task.wait(STAY_OPEN)
	closeTween:Play()
	closeTween.Completed:Wait()

	prompt.Enabled = true
	isBusy = false
end)

Not working? Common mistakes

The door falls through the floor or flies away when the tween plays.

Select the Door part and turn on Anchored. Tweening the CFrame of an unanchored part fights the physics engine.

Nothing happens when I press E.

Make sure the prompt is inside Door and still named ProximityPrompt, that you used a Script and not a LocalScript, and read the Output window for red errors.

The door spins around its middle instead of its edge.

The hinge maths uses Size.X as the door width. Resize the door so the width is X, the height is Y and the thickness is Z, then rotate it into place.

The door handle stays behind when the door opens.

Weld the handle to the door with a WeldConstraint and unanchor only the handle, or combine both parts into one Union.

How to make a door in Roblox Studio: what you will build

If you have been searching for how to make a door in Roblox Studio that feels like a real game door, this is it. When a player walks close, a small Press E label appears. They press E (or tap it on a phone), the door swings open on its hinge, stays open for three seconds and then swings shut on its own.

You only need three things:

  • A Part that is the door itself.
  • A ProximityPrompt inside it. This is the built-in Roblox object that shows the press E to open door message and tells your script when a player used it.
  • A Script that uses TweenService to animate the door smoothly instead of teleporting it.

The same script can also make a sliding door, like a sci-fi hangar or a shop entrance. You switch between swing and slide by changing one word. Once you understand this proximity prompt door, you can reuse the idea for chests, levers, elevators and secret walls.

How the Roblox tween door script works

Every Part has a CFrame: its position plus its rotation. The script saves the closed CFrame when the game starts, then calculates an open CFrame. For a swinging door it turns the part 90 degrees around its left edge, which acts as the hinge. For a sliding door it simply moves the part sideways by its own width.

TweenService then animates between those two CFrames. A tween needs three things: the object, a TweenInfo (how long and what easing style) and a goal, for example { CFrame = openCFrame }. Quad easing makes the door start fast and slow down at the end, which looks natural.

The debounce is the isBusy variable. Without it, a player spamming E would start new tweens while the old ones are still running and the door would jitter. With it, extra presses are ignored until the door has fully closed. The script also hides the prompt while the door is open, so players are not confused by a label that does nothing.

Because this is a normal Script (server side), every player in the server sees the door move at the same time. That is the whole idea behind how to make a door in Roblox Studio properly: server script, anchored part, tween, debounce.

Level up your door: locks, keys and sounds

Once the basic roblox tween door script works, try these upgrades. Each one is a small change and a great way to practise.

  • Sliding door: set SLIDE = true. Try Enum.EasingStyle.Back for a bouncy sci-fi feel.
  • Hold to open: set the prompt's HoldDuration to 1 so players must hold E for a second, great for vault doors.
  • Better labels: set ActionText to Open and ObjectText to Front Door so the prompt reads clearly.
  • Coin door: the Triggered event gives you the player who pressed E. Check their coins in leaderstats and only open if they can pay. Our leaderboard tutorial shows how to add coins.
  • Sound: put a Sound inside the door and call Play() right before openTween:Play().

Doors are also a classic obby checkpoint gate. Pair this with our obby tutorial and the double jump script to build your first mini game.

Parent note: what your child practises here

This looks like a small feature, but it covers real programming ideas: variables (OPEN_TIME, STAY_OPEN), events (the script waits for Triggered instead of checking constantly), conditions (if SLIDE then...), and state (the debounce flag). These are the same building blocks used in Python and web development.

Roblox Studio is free and runs on Windows and Mac. Building and testing happen on your own computer, and even a published game stays private by default, so no chat or strangers are involved while practising this tutorial.

A good sign of progress: your child can explain why the door must be Anchored and what would happen without the debounce. If they get stuck, that is normal. Reading the Output window and fixing one error at a time is the most important skill a young developer learns.

Want your child to build full games like this?

Want your child to build full games like this? First 1-on-1 lesson free.

At Excklusive-IT, Vlad Pomazanets teaches Roblox Studio and Luau in live 1-on-1 lessons on Zoom (60 minutes, ages 8–17). Learning how to make a door in Roblox Studio is a great first step; in lessons, students build their own game step by step: doors, checkpoints, coins, shops and their own ideas. Lessons are in English, Ukrainian or Russian, and we will match a time in your time zone.

After the free first lesson, it is CA$280 for 4 lessons (CA$70 per lesson), and unused lessons are refundable within 14 days. Families near Hamilton, Ontario can also study in person.

Book the free Roblox class or see the full Roblox course.

Questions parents ask

Should I use a Script or a LocalScript for a door?

Use a normal Script inside the door part. A Script runs on the server, so when the door opens every player in the server sees it open. A LocalScript would only move the door on one player's screen, so other players could still bump into a door that looks open to someone else.

Can the door open when a player touches it instead of pressing E?

Yes. You can connect to the part's Touched event instead of the prompt's Triggered event and keep the same tweens and debounce. The ProximityPrompt is usually better though, because players choose when to open it and it shows a clear button on computers, phones and controllers.

How do I make a locked door that needs a key?

Inside the Triggered function you get the player who pressed E. Check whether that player owns a key, for example a Tool named Key in their Backpack or enough coins in leaderstats. If they do not, return early and the door stays shut. You can change ObjectText to Locked to show the player why.

Why use TweenService instead of just setting the CFrame?

Setting the CFrame directly teleports the door from closed to open in a single frame, which looks cheap. TweenService calculates all the in-between positions for you, so the door moves smoothly over the time you choose, with easing that makes the motion feel natural.

Does the ProximityPrompt work on phones and controllers?

Yes. On a keyboard the default key is E, on a gamepad the default button is X, and on touch screens players tap the prompt that appears near the door. You can change KeyboardKeyCode and GamepadKeyCode in the Properties window if you want different buttons.

Is it too hard for a 9-year-old to learn how to make a door in Roblox Studio?

With a parent or teacher nearby, most 9-year-olds can build this door by following the steps and pasting the script. Understanding every line usually takes a few lessons. In our 1-on-1 classes younger students start with simple parts and events, then come back to doors like this one.

Want your child to build full games like this?

The first 1-on-1 Roblox lesson is free: 60 minutes live on Zoom with Vlad, in English, Ukrainian or Russian. We'll match a time in your time zone.

Book a free lesson

Book a free lesson

Money-back guarantee Not a fit? Unused lessons are refunded within 14 days.
CA$70 per 60-min private lesson ≈ US$50. Large US schools charge US$60–75 for 50–60 minutes.
One mentor, live, 1-on-1 English, Ukrainian or Russian. Vulnerable Sector Check. Parents welcome to watch.
★ What parents say

5 / 5 · 1 review

★★★★★

“We were looking for coding classes for kids in Hamilton and a friend recommended Exclusive-IT. My 11-year-old started the Roblox course one-on-one and built his first real game in a few weeks. The mentor is patient, the lessons are in plain English, and my son actually looks forward to them. Highly recommend for any parent who wants their child to learn to code.”

Parent · Hamilton · Roblox