Trigger.TouchEnded:Connect(function()
if debounce == false then
debounce = true
for i = 0,1,.01 do
wait()
Door.CFrame = Door.CFrame:Lerp(ClosedPos.CFrame, 0.2)
end
debounce = false
end
end)
Another problem with the code is that it’s always lerping between the current position and the end position.
(EDIT: I did not notice that this was what you intended, sorry)
So at first the door goes to 0.1 of the way to the end. Then it goes to 0.2 of the way between 0.1 of the way and the end, not to 0.2 of the way to the end.
Lerp between the start position and end position, not the current position and end position.
Trigger.TouchEnded:Connect(function()
if debounce == false then
debounce = true
local OpenPos = Door.CFrame
for i = 0,1,.01 do
wait()
Door.CFrame = OpenPos:Lerp(ClosedPos.CFrame, i) -- also replaced 0.2 with i
end
debounce = false
end
end)