Problem when tweening part

I am creating a placement system, and when a player picks up a part, they get to move it around. This code is under a renderstepped which tweens the primary part every frame. This all worked fine until I tested with players that have different FPS. I noticed that the player’s FPS is relative to how smooth the part travels when they are carrying it. For example, if their FPS is 144 it is smooth, but when it is 60 it is not smooth. I’ve tried solving this using delta time and I could find a solution. I believe the solution to this is through the use of delta time but I do not know how I would go about using it in this case

144 fps
https://gyazo.com/9bac4867864cf92014893c08be8890ac

60 fps
https://gyazo.com/e0772aba7a1b22230d7de9c436b199b5

renderstepped has a parameter that is the delta time of the last step and the current step. Im pretty sure you can create the tween with the tween time equal to either the delta or the delta * any number.

1 Like

I’ve tried making the tween speed (delta * speed), but it still didn’t look the same on different fps

Yes, you’re correct delta time would fix your issue but you shouldn’t use tweens inside of RenderStepped event but instead :Lerp(), here’s an example

self.instance.PrimaryPart.CFrame = self.instance.PrimaryPart.CFrame:Lerp(workspace.CurrentCamera.CFrame * Vector3.new(0, 0, -cameraOffset), math.min(deltaTime * 2, 1))

Play around with the math.min() formula to adjust the rigidness to your liking.

1 Like

Right before I saw your post I wrote this code

		self.instance.PrimaryPart.CFrame = self.instance.PrimaryPart.CFrame:Lerp(CFrame.new(workspace.CurrentCamera.CFrame * Vector3.new(0,0,-cameraOffset)),dt * 6)
2 Likes