Forja

Roblox door script

A door that slides open and closed. Players press E, or tap the prompt on a phone.

Where it goes

  1. 1Add a Part for the door and turn on Anchored. Make it wider than it is thick, along its X side.
  2. 2Hover over it in the Explorer, press + and choose Script.
  3. 3Delete what's in the Script, paste this in and press Play. Walk up to it and press E.
Door · a Script in the door Part
-- From forja.us/tools/roblox-scripts/door-- A door that slides open and closed with a prompt.local TweenService = game:GetService("TweenService")local door = script.Parentlocal closed = door.CFramelocal open = closed * CFrame.new(door.Size.X, 0, 0)local slide = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)local prompt = Instance.new("ProximityPrompt")prompt.ActionText = "Open"prompt.ObjectText = "Door"prompt.Parent = doorlocal isOpen = falseprompt.Triggered:Connect(function()	isOpen = not isOpen	prompt.ActionText = isOpen and "Close" or "Open"	TweenService:Create(door, slide, { CFrame = isOpen and open or closed }):Play()end)

How it works

  • A ProximityPrompt shows the "press E" button when a player is close, on every device.
  • CFrame.new(door.Size.X, 0, 0) is one door's width to the side, so it slides clear of the opening.
  • TweenService moves it smoothly instead of jumping.

Make it yours

Slide the other way
Use -door.Size.X.
Close by itself
After Play(), add task.wait(3) and close it again.
Want something more? The script generator can write it: “A door that only opens for players holding a tool named Key, and closes by itself after 3 seconds”

Maps to try it on: horror maps

Start from a finished map, and your scripts have a game to run in.

More free Roblox scripts