http://prntscr.com/63quna - I have no clue how to add the script here like it is in the Studio, so I screenshoted it, is there any way to make it smoother...?Like just to close and open smoother?
Since I'm too lazy to rewrite all of that code, I'll explain my method instead, using placeholder CFrame stuff.
wait
s in ROBLOX always way at least .03 seconds. Your waits do that, too, even though you set them smaller. This is a hard limit that cannot be changed globally.
The easiest way to go about this is to use something called a time delta:
--This is a purely linear interpolation. It may not look very pretty, but it will work. local openTime = 4 --seconds local openTarget = CFrame.new(0, 5, 0)*CFrame.Angles(0, math.pi, 0) local closedTarget = CFrame.new(0, -3, 8) local deb = false local open = false local door = script.Parent function toggleDoor() local dt = 0 local t = tick() initial = open and openTarget or closedTarget final = open and closedTarget or openTarget local done = false while not done do dt = tick() - t local newTarget = {} if dt/openTime < 1 then for i = 1, 12 do newTarget[i] = initial[i] + (final[i] - initial[i])*(dt/openTime) end -- initial + (final-initial)*(percentage) = initial + (totalDisplacement)*(percentage) -- = initial + percentageDisplaced = currentPosition else newTarget = final done = true end door.CFrame = CFrame.new(newTarget[1], newTarget[2], newTarget[3], newTarget[4], newTarget[5], newTarget[6], newTarget[7], newTarget[8], newTarget[9], newTarget[10], newTarget[11], newTarget[12],) wait() end end do local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = openTarget:components() openTarget = {x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22} local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = closedTarget:components() closedTarget = {x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22} end script.Parent.ClickDetector.MouseClick:connect(function() if deb then return end deb = true toggleDoor() open = not open deb = false end)