For those that how to make a Door Tween like a Garage

  • List item

Your tutorials can be on any development topic, as long as it is related to Roblox development, and as long as it conveys a significant amount of information. Topics that are not about (Roblox) development should probably go into a different forum category, as well as topics that are really simple or short.

Make sure to add step-by-step instructions in your tutorials! You should detail and explain your steps as best you can, and remember that not everyone might have your particular set of skills.

When possible, be sure to include images or videos to make your explanation as clear and easy to follow as possible.

Please consider using Community Resources category if your topic does not fit the format of a tutorial.

local doorPart = game.Workspace:WaitForChild(“DoorPart”)
local openSound = doorPart:WaitForChild(“OpenSound”)
local closeSound = doorPart:WaitForChild(“CloseSound”)

local isOpen = false
local canOpen = true

--------- Cooldown Door Settings ---------
local cooldownTime = 10
local lastOpenTime = 0

local openPosition = doorPart.Position + Vector3.new(0, 8, 0)
local closedPosition = doorPart.Position

local doorStayOpenTime = 5

--------- Door Distance Settings ---------
local proximityDistance = 10

local function OpenDoor()
local currentTime = tick()
print(“Attempting to open the door…”)

if not isOpen and canOpen and (currentTime - lastOpenTime >= cooldownTime) then
	local tweenInfo = TweenInfo.new(2.5)
	
	--------- Tween Door Open Settings ---------
	local tween = game:GetService("TweenService"):Create(doorPart, tweenInfo, {Position = openPosition})
	tween:Play()

	local randomPlaybackSpeed = math.random(90, 110) / 100
	openSound.PlaybackSpeed = randomPlaybackSpeed

	openSound:Play()
	print("Door opened. Playback speed: " .. randomPlaybackSpeed)
	
	--------- Tween Door Close Settings ---------
	local function CloseDoor()
		local tweenInfo = TweenInfo.new(1.4) 

		local tween = game:GetService("TweenService"):Create(doorPart, tweenInfo, {Position = closedPosition})
		tween:Play()

		closeSound:Play()
		isOpen = false
		print("Door closed.")
	end

	isOpen = true
	lastOpenTime = currentTime
	canOpen = false

	wait(doorStayOpenTime)
	CloseDoor()

	wait(cooldownTime - doorStayOpenTime)
	canOpen = true
end

end

local function CheckProximity(player)
local character = player.Character
if character then
local distance = (doorPart.Position - character.HumanoidRootPart.Position).Magnitude
if distance <= proximityDistance then
OpenDoor()
end
end
end

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while wait(1) do
CheckProximity(player)
end
end)
end)

  • List item[quote=“MasterPixelVerse_YT, post:2, topic:2566296, full:true, username:atompest”]
    local doorPart = game.Workspace:WaitForChild(“DoorPart”)
    local openSound = doorPart:WaitForChild(“OpenSound”)
    local closeSound = doorPart:WaitForChild(“CloseSound”)

local isOpen = false
local canOpen = true

--------- Cooldown Door Settings ---------
local cooldownTime = 10
local lastOpenTime = 0

local openPosition = doorPart.Position + Vector3.new(0, 8, 0)
local closedPosition = doorPart.Position

local doorStayOpenTime = 5

--------- Door Distance Settings ---------
local proximityDistance = 10

local function OpenDoor()
local currentTime = tick()
print(“Attempting to open the door…”)

if not isOpen and canOpen and (currentTime - lastOpenTime >= cooldownTime) then
	local tweenInfo = TweenInfo.new(2.5)
	
	--------- Tween Door Open Settings ---------
	local tween = game:GetService("TweenService"):Create(doorPart, tweenInfo, {Position = openPosition})
	tween:Play()

	local randomPlaybackSpeed = math.random(90, 110) / 100
	openSound.PlaybackSpeed = randomPlaybackSpeed

	openSound:Play()
	print("Door opened. Playback speed: " .. randomPlaybackSpeed)
	
	--------- Tween Door Close Settings ---------
	local function CloseDoor()
		local tweenInfo = TweenInfo.new(1.4) 

		local tween = game:GetService("TweenService"):Create(doorPart, tweenInfo, {Position = closedPosition})
		tween:Play()

		closeSound:Play()
		isOpen = false
		print("Door closed.")
	end

	isOpen = true
	lastOpenTime = currentTime
	canOpen = false

	wait(doorStayOpenTime)
	CloseDoor()

	wait(cooldownTime - doorStayOpenTime)
	canOpen = true
end

end

local function CheckProximity(player)
local character = player.Character
if character then
local distance = (doorPart.Position - character.HumanoidRootPart.Position).Magnitude
if distance <= proximityDistance then
OpenDoor()
end
end
end

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while wait(1) do
CheckProximity(player)
end
end)
end)

You can also create a Model then rename GatewayVista to connect the script with a model local gatewayVista = game.Workspace:WaitForChild(“GatewayVista”)
local doorPart = gatewayVista:WaitForChild(“DoorPart”)
local openSound = doorPart:WaitForChild(“OpenSound”)
local closeSound = doorPart:WaitForChild(“CloseSound”)

local isOpen = false
local canOpen = true

--------- Cooldown Door Settings ---------
local cooldownTime = 10
local lastOpenTime = 0

local openPosition = doorPart.Position + Vector3.new(0, 10, 0)
local closedPosition = doorPart.Position

local doorStayOpenTime = 5

--------- Door Distance Settings ---------
local proximityDistance = 10

local function OpenDoor()
local currentTime = tick()
print(“Attempting to open the door…”)

if not isOpen and canOpen and (currentTime - lastOpenTime >= cooldownTime) then

	--------- Tween Door Open Settings ---------
	local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)

	local tween = game:GetService("TweenService"):Create(doorPart, tweenInfo, {Position = openPosition})
	tween:Play()

	local randomPlaybackSpeed = math.random(90, 110) / 100
	openSound.PlaybackSpeed = randomPlaybackSpeed

	openSound:Play()
	print("Door opened. Playback speed: " .. randomPlaybackSpeed)

	--------- Tween Door Close Settings ---------
	local function CloseDoor()
		local tweenInfo = TweenInfo.new(1.4, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)

		local tween = game:GetService("TweenService"):Create(doorPart, tweenInfo, {Position = closedPosition})
		tween:Play()

		closeSound:Play()
		isOpen = false
		print("Door closed.")
	end

	isOpen = true
	lastOpenTime = currentTime
	canOpen = false

	wait(doorStayOpenTime)
	CloseDoor()

	wait(cooldownTime - doorStayOpenTime)
	canOpen = true
end

end

local function CheckProximity(player)
local character = player.Character
if character then
local distance = (doorPart.Position - character.HumanoidRootPart.Position).Magnitude
if distance <= proximityDistance then
OpenDoor()
end
end
end

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while wait(1) do
CheckProximity(player)
end
end)
end)