Rotating a Character's Head to Follow Camera Server Sided

How would I go about doing this server sided. Doing the client side is no biggy, however I want to know how I could accomplish this server sided efficiently.

One way to go about this is to send the Camera CFrame direction to the server, have the server modify the character and from there it could do this to all characters. However, wouldn’t this be a very inefficient way to do this? Especially to clog RemoteEvents/RemoteFunctions? I’d also not want to stress the server so much for rapidly changing all the character heads.

So my question is, is there a special property to accomplish this in Humanoid? Or am I just left with Invoking/Firing the server to change the head rotations?

Thank you!

There is a similar post here, however they only list the Invoke/Fire as a possible option and I’m curious if there’s any better ones.

Sorry, I misread the question, withdrawing post.

Edit: As far as I know, I do not know any special humanoid for this.

How I did mine was, the client has a script that rotates the head and sends the server the CFrame info it used prior to rotation. The server gets the info and makes the necessary replication.

To answer your question, @someonedie is correct, there is no humanoid property for this kind of behaviour.

1 Like

I always thought that you could do this kind of stuff client sided without remotes? The client has network ownership of their character.

@wevetments, How often did you have the client invoke the server?

You can do it on the client no problem, but it won’t replicate over to the server, and then to other clients.

1 Like

My current setup is I have dedicated remote events for each client to avoid the scenario where I stress a single remote event.

My script currently invokes the server whenever the client moves the camera, however I believe that you can further optimise this by rounding the integers to a whole number (For instance, 15 instead of 14.8) and once the integer increments by 1 (the higher the increment the rougher the transition of the replication looks like), that would be the time you would invoke the server.

2 Likes

Integers of what exactly? The difference in moved direction?

I mean like, the CFrame value is an integer or a set of integers. When rotating the head, I guess you used the CFrame. Angles function which returns 3 integers. Round off the integers that will be used and once those integers increment, you would then invoke the server to reduce performance stress

Oh duh. My bad. Thank you!

I did some experimentation over the last couple days, and I managed to do it, however it’s choppy and consumes a lot of network/server time to process up to 14 people’s heads/torsos. How did you do your integer thing? How could I make this more efficient where it isn’t choppy, but still doesn’t consume a lot of bandwidth/processing power?

1 Like

I had this exact challenge with a ;laserEyes command I developed a few weeks back. Here’s the method behind it:

  1. The client controlling the head calculates all the necessary CFrames and sets their head to this value, real-time.

  2. Every 1/2 a second, the client sends their latest CFrame information to the server. The server then verifies this information and fires to all other clients. You could also limit the players to send this data to based on their environment. For example, ignore players who are greater than 200 studs away from the sender as they will be unable to see him/her in the first place.

  3. On the clients who receive this data, use TweenService to update the sender’s head accordingly. By doing this, the sender’s head will appear to rotate smoothly, despite only being updated twice a second.

Here’s an example of what it looks like for the receiver (left) and sender (right):

17 Likes