Door is not opening completely after the first time it's interacted with

As the title says, the door I’ve made doesn’t completely open/close after the first time it’s interacted with.

I believe the problem stems from this excerpt of code in my script:

local finish = Door.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
RunService.Heartbeat:Connect(function(d)
	local cfm = Door.PrimaryPart.CFrame:lerp(finish,d*3)
	Door:SetPrimaryPartCFrame(cfm)
end)

I’m not very familiar with the Heartbeat function, so that’s likely what I’ve messed up on, just I’m not quite sure where exactly I went wrong.

Hey there. I am quite confused as to why you are attaching the door to heartbeat. Heartbeat runs every frame, and that is based off a Variable frequency depending on the machine ruinning.

I originally had it set up to a loop, but it proved to be incredibly choppy after some 10+ players had joined the game. I switched it to heartbeat because of this wiki article and this reply to another forum post. The intention is to make the door move smoother.

Is the door a rotating one? Is it something that you always want to be running? Or do you just want it based off a touch?

Yes, the door is a rotating one. It’s not always running and only rotates when a player is close enough and presses the ‘E’ key.

You should just disconnect the Heartbeat once the door is at it’s proper position open or close.

I’m not exactly sure what you mean by disconnect the Heartbeat?