Best way to get mouse.hit from client?

Right now I have a remote event in replicated storage and I fire the specific client when I need the mouse.hit. The client then fires back to the server with the mouse.hit. Is this the best way to do it?

Hey!

Just a heads-up: grabbing mouse.hit info from a player’s side and sending it over to the server might not be the best idea, and here’s why:

  1. Delay Issues: When you ping the server with a RemoteEvent, there’s bound to be some lag. So, there’s gonna be this tiny pause from when you ask for that mouse.hit and when you get it.
  2. Can We Trust It?: Some players might get cheeky and mess with the client-side. So if you’re banking on that mouse.hit data being legit, remember that there’s always a chance someone’s trying to pull a fast one on you.
  3. Too Much Chatter: Asking for the mouse.hit position a lot? Like, all the time? That’s a heap of back-and-forth with the server. And that can slow things down, especially for those on shoddy Wi-Fi.

But hey, I get it. Sometimes, you really need to know where the player’s pointing or clicking. So what can you do?

Well, think about these:

  1. Keep It Local: Maybe decide things on the player’s side without always asking the server. Especially if it’s just for looks and doesn’t really affect gameplay.
  2. Chill on the Requests: If you gotta know the mouse.hit often, maybe don’t ask every single frame. Take a breather, and ask every few frames or when things really change.
  3. Double-Check: If that mouse.hit is super important for the game, like scoring a hit in an FPS, take the client’s word with a grain of salt. Check it on the server to make sure it’s on the up-and-up.

Hope that helps! :+1: