Tweening part orientation; server vs client

Hello,

In my game I have a part that is constantly rotating. It’s not just a special effect it’s critical for gameplay. Right now, I am tweening the orientation on the server, but I’ve heard that it’s better for performance to tween on the client. However, I don’t want players to manipulate this orientiation and cheat. How can I make sure I have good performance in my system while also being secure? I’ve looked at other posts about tweening on the server va client, but I haven’t found any definitive answers for my situation.

Edit: All right, I’ve been struggling with this. I tried the hinge constraint, but it only works on one axis and I need it to work on every axis. The part that I want to rotate also needs to be suspended in the air and when the parts not anchored that isn’t possible. I tried using run service to constantly update the position, but that was very laggy for the client. I’ve used angular velocity, but that doesn’t keep the part in position. It starts moving like crazy. I’m not sure what to do.

You have to do it on the server and should only do things that are entirely visual on the client so that the roblox server doesn’t need to handle all of it.
Running a single Tween doesn’t impact the performance.

Are you sure it won’t cause lag? I can visibly tell that the tween is not moving smoothy.

Too hard to explain this, so this makes a part and rotates it. No tween needed.

-- ServerScriptService.Script

local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 4)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = false
part.Parent = workspace

local anchor = Instance.new("Part")
anchor.Size = Vector3.new(4, 1, 4)
anchor.Position = Vector3.new(0, 5, 0)
anchor.Anchored = true
anchor.Transparency = 1
anchor.CanCollide = false
anchor.Parent = workspace

local a0 = Instance.new("Attachment")
a0.Orientation = Vector3.new(0, 0, 90)
a0.Parent = anchor

local a1 = Instance.new("Attachment")
a1.Orientation = Vector3.new(0, 0, 90)
a1.Parent = part

local hinge = Instance.new("HingeConstraint")
hinge.Attachment0 = a0
hinge.Attachment1 = a1
hinge.ActuatorType = Enum.ActuatorType.Motor
hinge.MotorMaxTorque = 100000
hinge.AngularVelocity = 1.57
hinge.Parent = anchor

You can copy it after you run it, then paste it back into the Workspace afterward to see exactly how it works.

1 Like

You can also run a tween on the server and on the client at the same time.

2 Likes

If the rotation is constant, you may want to look into motors, torques, or velocity instances that may replicate it more accurately than a tween.

1 Like

Thank you everyone for the help, I will try these suggestions later today and we’ll see how it goes :slightly_smiling_face: