Server vs. Local handling of CFrame operations

I’m working on a “secure facility,” for which I am making code-doors, hatches, gates, etc… Some of those systems involve moving parts using CFrame.new & CFrame.Angle. As of now, all of the CFrame operations are handled via server-scripts inside the models themselves. I have recently received some advice that this may cause stutter on clients that are connected to the server w/ high ping- which makes me question the viability of handling CFrame via server script as opposed to using a server script to trigger functions in local scripts. I have a few main concerns/questions-

Question 1: I am moving models of various different part counts and sizes, do stutter problems occur more frequently the larger/higher part count a model is, or does it occur irrespectively of those properties and entirely proportional to a client’s ping?

For example, should I be as concerned with a keypad (relatively small w/ low part count) as I am about a large(ish) high part-count model? (See below)

Keypad Hatch

Question 2: Is it worth the trouble of including the local script along with the server script as opposed to including just a server script and maintaining better organization?

As it stands, I have very organized model-hierarchies which store the parts of the model and scripts within a single model. If I wanted to export the models into a different game dragging-and-dropping the model wouldn’t be a hassle at all. If there were a local script (or a few)- wouldn’t I have to store those separately outside the model (such as in one of the provided services like StarterGUI or something)? If so, implementing those same models in other games would require a lot more work because I would have to individually move scripts between games as well. (Unless there is a way to prevent this? See Q3)

Question 3: Is there a way of storing local scripts inside of a model and then sending them out to the clients as needed? (In order to address concerns from Q2)

This assumption (that it needs to be stored outside the model) is based on some advice that I got, and I’m still not entirely sure that it’s accurate.

tl;dr - Is there a hard and fast rule for when to use server scripts to handle CFraming vs. Local scripts in conjunction with server scripts? Should you always use one or the other?

(Also I’d just like to take a moment and say hi, this is my first post on the devforum as a new member :slight_smile: )

3 Likes

From my personal experience with CFraming / Tweening / that stuff, I’ve always found it in the best interest to handle the movement locally, and then replicate it to the server (end-product only), and to the other clients ( movement + end product).

Ex.

LocalScript in PlayerStarterScripts handles all door/hatch movement,

On client interact / object movement, fire a remote event to the server so that the server will replicate it to the other clients.

On interaction finished / movement finished, fire the remote event and tell the server to update the object to its endpoint CFrame.

In regards to your questions:

Q1: No it usually doesn’t matter.

Q2: Yes and sometimes handling it locally can be a lot more organized.

Q3: Not that I’m aware of which is why in this case I think I’d be best to have it all handled in a single localScript in PlayerStarterScripts

5 Likes