I’m looking for a way to make doors move smooth consistently. The current method I’m using (cframe in a for loop), but I find it is choppy at times especially when a larger number of players (10+) are within the game. I’m not entirely sure how to use these methods, but here are the ones I’m aware of:
Heartbeat loop w/ cframe – couldn’t get this one to work and couldn’t get any help. This is the only one I tried before giving up because it just didn’t work.
RenderStep
Tweening
Here is the current code I’m using to make the door open which I’d like to improve/replace:
local finish = Door.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,1,.1 do
local cfm = Door.PrimaryPart.CFrame:lerp(finish,i)
Door:SetPrimaryPartCFrame(cfm)
wait()
end
TweenService is probably the easiest way to manage this. It’s got a lot more customisation than regular lerping, unless you plan to program in your own styles.
RenderStep is actually what you ought to be using instead of Heartbeat. The code will be the same, but it’s just a performance difference. I can’t remember the exact technical reasons, but RenderStep should be used instead of Heartbeat for visual things (such as this door). For when you’re interacting with physics, you should use Heartbeat.