Get updated HumanoidRootPart LookVector

I have a little ability that, whenever you press Q, it activates. It first plays an animation upon activating, and also calls the remote event to the server. I have a delay in the server to sync up with the animation, which is a throw animation, so when the animation is about finished, it will then start the ability script in the server. However, because I delayed the function in the server of about half a second, the humanoid root part look vector parameter sent from the client will be the look vector from half a second ago. Is there any way I find a work around this? I thought about using a remote function to get the current HumanoidRootPart LookVector, and I also though about just delaying it on the client. But I don’t want exploiters to instantly fire the event without having any delay. Any help would be appreciated. If you want me to further clarify I can explain more. Thanks.

1 Like

And I don’t just get the HRP LookVector on the server because it’s not accurate and is delayed a little because of it’s the server. the client is way more accurate.

Why aren’t you doing a task.delay on the client instead, then firing the server with the look vector? There is no reason to fire server early, at least with the information you’ve given.

I don’t want exploiters to fire the remote before they are supposed to, so I decided to delay on the server. Or are exploiters not able to do that? Let’s say I want an ability to charge up for 5 seconds, then eventually shoot at the given HumanoidRootPart. Couldn’t the exploiters just instantly fire the remote without delay?

1 Like

Even with 5 seconds delay, they can fire it as much as they want 5 seconds ago.

The only way around it is server side checks, if you are concerned with that at this point. For example, you could fire the server at the start of the animation (with the name of it), use the name to check how long it should wait until firing, then the client could fire the server with the root look vector. If the time is approximately correct on the server with how long it should take for that animation, only then shoot.

This is how I would do it, if I really cared to put a lot of work into making it look accurate.
And really you have to decide is it really worth the extra work.

  1. detect the ability being activated on the client and start the animation on the client
  2. fire event to server, server checks if it has been long enough delay to prevent spamming
  3. if it has been long enough delay, server fires projectile to target based on cframe of the client when the even happened (you can either tell the sever what time the action happened on the client, or send the cframe to the server)
  4. if however it was not a long enough delay (client is hacking and spamming the action) server can tell the client to stop the animaton, and server will not do the action

Its all about timing and illusion. On the player’s client they see the animation happen immediately and a false projectile fire.
On the server, the real projectile is being fired, and damage caluclated
On everyone else’s client, they see a delayed animation (due to latency) with the projectile firing to the target (from the server firing it)

Would an optimal solution be just using a remote function to get the HumanoidRootPart LookVector? Or would another one be just playing the animation server sided instead of client sided

The main problem is that, I want to play an animation, then after a little delay (because it takes time for a ‘swing’ animation to ‘swing’), the projectile is then thrown. The most simple way is just by delaying it on the client, but I want to prevent exploiters from being able to use the ability before the delay is finished. Delaying on the server will not work, because when the projectile is thrown, it will be thrown at the HumanoidRootPart position however long the delay is

I thought about this: Playing animation on server, or using a Remote Function to get the HumanoidRootPart LookVector from the client.

Do what you need to do on the client, and play the animation on the client.
Use a debounce to stop the client from doing it again until it finishes
Double check this debounce delay on the server to make sure they didn’t cheat

When you fire the remote event to the server, give the lookvector of the client and the time the animaiton started, then the server can see if it needs to wait a bit, or not, and fire the projectile based on the lookvector it was sent.

There will always be the same amount of delay, to make it look like the character is actually throwing the projectile. My problem is that the position passed from the client is what the current position of the humanoid root part was however long the delay is, because I have a delay on the server. I want to figure out a way to get the current position of the client’s humanoidrootpart without referencing it on the server, because the server is a little delayed in getting positions. The client is much faster and more reliable

Why not just get the LookVector from the server?

Because it’s delayed, and if you’re moving forward, it appears a little bit behind you, which is a problem if you are turning really fast, then it would still fire at the old place you were looking at. That’s why using client is better because it’s instant

Just get the look vector after the delay.

You can not send the server the clients current lookvector faster than having the server, just look at the character and read it directly.

By doing what? Using a remote function. I think that could work but Idk how secure it is

The server look vector has a little delay, so it’s not exactly the actual look vector, because it’s the server. However, the client has instant response time, i guess, and it sends the exact look vector without much delay at all

The cost of firing a remote event once with a single unit vector seems much smaller. You don’t have to worry about optimization here.

It’s not about optimization it’s about accuracy, when I reference the LookVector on the server, it’s not exact because the server has some delays between the client, but when I reference it on the client and send it to the server, it is exactly where it’s supposed to be, because the client can see where it currently is, while the server needs to replicate and stuff, or whatever the server does.

I have never encountered such an issue; generally I find the server to be pretty accurate when getting the LookVector of a character’s HRP, have you tested it? Also, you need to get the LookVector after the delay on the server to get the latest change.