How to make this door smooth

I’ve got this simple click door system. I don’t know how to make it turn smoothy with scripting, so I’ve resorted to using literal models and setting their transparency to 0. The problem is that it looks garbage. So I’ve finally opened up to the idea of smooth doors using only 1 model. Thing is I don’t know how. Help?

Previous garbage code:

local Detector = script.Parent.ClickDetector

local Door = script.Parent.Parent

local debounce = false -- cooldown setup

Detector.MouseClick:Connect(function(Player)
	if debounce then return end -- cooldown code
	debounce = true
	
	local char = Player.Character
	
	local humanoid = char.Humanoid	
	
	local OpenAnim = humanoid:LoadAnimation(script.OpenAnimation)
	
	OpenAnim:Play()
	
	Door.ClosedModel.DoorKnob.Transparency = 1 -- disable the closed door
	Door.ClosedModel.DoorKnob.CanCollide = false
	Door.ClosedModel.DoorKnob.CanQuery = false
	
	Door.ClosedModel.DoorModel.Transparency = 1
	Door.ClosedModel.DoorModel.CanCollide = false
	Door.ClosedModel.DoorModel.CanQuery = false
	
	Door.ClosedModel.Glass.Transparency = 1
	Door.ClosedModel.Glass.CanCollide = false
	Door.ClosedModel.Glass.CanQuery = false
	
	wait(0.1)
	
	Door.HalfwayModel.DoorKnob.Transparency = 0 -- enable the halfway door
	Door.HalfwayModel.DoorKnob.CanCollide = true
	Door.HalfwayModel.DoorKnob.CanQuery = true

	Door.HalfwayModel.DoorModel.Transparency = 0
	Door.HalfwayModel.DoorModel.CanCollide = true
	Door.HalfwayModel.DoorModel.CanQuery = true

	Door.HalfwayModel.Glass.Transparency = 0.5
	Door.HalfwayModel.Glass.CanCollide = true
	Door.HalfwayModel.Glass.CanQuery = true
	
	wait(0.2)
	
	Door.HalfwayModel.DoorKnob.Transparency = 1 -- disable the halfway door
	Door.HalfwayModel.DoorKnob.CanCollide = false
	Door.HalfwayModel.DoorKnob.CanQuery = false

	Door.HalfwayModel.DoorModel.Transparency = 1
	Door.HalfwayModel.DoorModel.CanCollide = false
	Door.HalfwayModel.DoorModel.CanQuery = false

	Door.HalfwayModel.Glass.Transparency = 1
	Door.HalfwayModel.Glass.CanCollide = false
	Door.HalfwayModel.Glass.CanQuery = false
	
	wait(0.1)
	
	Door.OpenModel.DoorKnob.Transparency = 0 -- enable the open door
	Door.OpenModel.DoorKnob.CanCollide = true
	Door.OpenModel.DoorKnob.CanQuery = true

	Door.OpenModel.DoorModel.Transparency = 0
	Door.OpenModel.DoorModel.CanCollide = true
	Door.OpenModel.DoorModel.CanQuery = true

	Door.OpenModel.Glass.Transparency = 0.5
	Door.OpenModel.Glass.CanCollide = true
	Door.OpenModel.Glass.CanQuery = true
	
	
	
	wait(3) -- cooldown amount
	debounce = false
	
end)

You will probably want to tween your doorway open and closed… here is a simple tutorial on it:

1 Like