How To Make A Door That Opens With ProximityPrompt
Build a smooth swinging Roblox door using a ProximityPrompt, an anchored hinge part, TweenService, server-side key checks, and ProximityPromptService.
- Difficulty
- Beginner
- Time Needed
- 15 Minutes
- Core Instances
- Model (Hinge + Door), WeldConstraint, ProximityPrompt
- Trigger Event
- ProximityPrompt.Triggered (Supplies Triggering Player)
- Animation Service
- TweenService With CFrame.Angles
- Multi-Door Manager
- ProximityPromptService.PromptTriggered
Set Up The Door Hinge And ProximityPrompt
Tweening a rectangular door panel directly spins it around its dead center like a revolving wall rather than pivoting neatly from one side. To build a realistic swinging doorway, group two parts inside a Model named SwingingDoor: a visible panel named Door and a thin vertical part named Hinge positioned flush along whichever edge the door should pivot on (set Hinge's Transparency to 1 and CanCollide to false).
Insert a ProximityPrompt into the Door part—or, for pinpoint placement right over a doorknob, insert an Attachment onto the Door, drag the Attachment to the handle, and parent the ProximityPrompt inside that Attachment. Because ProximityPrompt automatically adapts its button badge for keyboards, gamepads, and touchscreens, one object supports desktop, console, and mobile players with zero extra UI scripting.
Configure Visibility Range And Cross-Platform Input
Select the ProximityPrompt in Explorer and tune five Properties to make the doorway feel responsive without cluttering the screen.
- ObjectText and ActionText: Label the object (such as Door) and the current verb (Open or Close).
- KeyboardKeyCode and GamepadKeyCode: Choose the interact keys (commonly E on keyboard and ButtonX on controllers).
- MaxActivationDistance: Sets how close a character must stand (typically 7 to 10 studs) before the prompt appears.
- HoldDuration: Leave at 0 for instant press-to-open doors, or raise to 0.5–1.5 seconds for heavy vault doors.
- RequiresLineOfSight and ClickablePrompt: Line-of-sight defaults to true so players cannot trigger doors through solid walls; note that phone and tablet users can always tap a prompt directly even if ClickablePrompt is set to false.
Animate The Door Smoothly With TweenService
Insert a server Script directly inside SwingingDoor and paste the Luau code below. The script ensures Hinge stays anchored while welding the unanchored Door panel to it, calculates the 90-degree open CFrame once at startup to avoid floating-point drift, and uses an isMoving lock so rapid presses cannot interrupt an active swing.
Because Triggered executes on the server and automatically passes the interacting Player as its first argument, you can enforce optional locked-door rules safely on the server—setting a Boolean Attribute named RequiresKey on SwingingDoor requires the player to carry a server-assigned HasKey Attribute before the hinge unlocks.
local TweenService = game:GetService("TweenService")
local doorModel = script.Parent
local hinge = doorModel:WaitForChild("Hinge")
local doorPanel = doorModel:WaitForChild("Door")
local prompt = doorModel:FindFirstChildWhichIsA("ProximityPrompt", true)
if not (hinge:IsA("BasePart") and doorPanel:IsA("BasePart") and prompt) then
warn("SwingingDoor requires Hinge, Door, and a ProximityPrompt.")
return
end
hinge.Anchored = true
hinge.CanCollide = false
doorPanel.Anchored = false
local weld = Instance.new("WeldConstraint")
weld.Part0 = hinge
weld.Part1 = doorPanel
weld.Parent = hinge
local tweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local closedCFrame = hinge.CFrame
local openCFrame = closedCFrame * CFrame.Angles(0, math.rad(90), 0)
local openTween = TweenService:Create(hinge, tweenInfo, { CFrame = openCFrame })
local closeTween = TweenService:Create(hinge, tweenInfo, { CFrame = closedCFrame })
local isOpen = false
local isMoving = false
prompt.ObjectText = "Door"
prompt.ActionText = "Open"
prompt.Triggered:Connect(function(player)
if isMoving then
return
end
if doorModel:GetAttribute("RequiresKey") and not player:GetAttribute("HasKey") then
print(player.Name .. " needs a key to open this door.")
return
end
isMoving = true
if isOpen then
closeTween:Play()
closeTween.Completed:Wait()
prompt.ActionText = "Open"
else
openTween:Play()
openTween.Completed:Wait()
prompt.ActionText = "Close"
end
isOpen = not isOpen
isMoving = false
end)Manage Many Doors Globally With ProximityPromptService
When a map grows to dozens of rooms, copying the same Script into every doorway makes maintenance tedious. Instead, use a single Script in ServerScriptService connected to ProximityPromptService.PromptTriggered, which receives both promptObject and player whenever any prompt in the place fires.
By checking an Attribute or CollectionService tag on promptObject.Parent, one central controller can animate every door, play opening audio, and track open/closed states cleanly from one file. For nearby double doors or neighboring lockers that share the same keycode, leave Exclusivity set to OnePerButton so Roblox displays only the prompt closest to the player's camera direction.
Fix Missing Prompts And Reversed Door Swings
If the interact prompt never appears in playtesting, check RequiresLineOfSight first: a thick ornamental doorframe or recessed Attachment buried slightly inside solid wood can block the raycast from the camera, so either nudge the Attachment outward toward the hallway or toggle RequiresLineOfSight off. Also verify that Enabled is true and MaxActivationDistance is large enough for the doorway depth.
If the door swings inward into furniture instead of outward into the corridor, simply flip math.rad(90) to math.rad(-90) on the openCFrame line. If the Hinge turns cleanly while the Door panel stays frozen in midair, confirm that Door has Anchored set to false—even one anchored child locks a welded assembly immobile.