I assume your talking about Client to Server communication, revolving around Ray-casts. I completely agree with your idea that remote events meant to be fired on the client from a Local-Script can also be fired from the Player’s client.
Another problem with this communication is how fast a player’s Internet Speed is, for example in a game called Murder Mystery 2 (aka MM2) someone can kill me from miles away but on my screen I was clearly not close.
After a bit of research I’ve concluded some theories and ideas you could try.
Server Authoritative Actions
This is where the Server has the final say on what you’ve done. and checks whether or not what you did was fine or not.
Briefly, this basically just prevents cheating, ‘illegal’ movements or actions. This is most likely the simplest option as depending on how fast your internet is, though there is some delay (the higher the ping the longer the delay), but this delay can be annoying - note that its less responsive…
If you’ve ever experienced playing a game and it took 1 second for it process that your pressing the W key, that is somewhat Server Authoritative Movement.
Pros
- Prevents Cheating
- Consistent Gameplay (Everyone sees what the server sees.)
- Better Control Over Multiplayer Interactions
Cons
- Increased Latency (Lag/Input Delay)
- Harder to Implement
- Higher Server Load
So unfortunately, some players will go crazy with this delay and probably leave a few comments on how slow your game is, Fortunately! we have Client-Side Prediction and Server Reconciliation
Client Side Prediction
We can use Client Side Prediction to ‘smoothen’ Server Authoritative Actions and make the game feel more responsive.
“The idea is to let the client temporarily predict the outcome of player actions (like movement) before receiving confirmation from the server. This way, the player sees immediate feedback for their actions, reducing the perception of lag.”
So before our Server Authoritative system takes action, we first apply the action anyway and wait for a response from the our System, If the server recalls the action as illegal it will return the players action; This is called Rubber Banding (Teleporting Back to where you were previously).
This confirmation/authorization is called Server Reconciliation (When the client receives the server’s response, it checks if its prediction matches the server’s authoritative result.) If it doesn’t match it or differs from its result, it will return it to where the Server Thinks you should be from its results.
Once that’s done, the Server’s results are sent to other clients, though this isn’t perfect, but it gets somewhere - this is coming from the Client 2 which sees us phasing we can do much more to fix this. From this point we’ve solved the problem with Lag.
Pros
- Responsive Gameplay
- Smooth User Experience
- Reduced Latency Impact
Cons
-
Reconciliation Jitter (When the client’s prediction is wrong, the game state can “snap” or jitter as the client corrects to the server’s position. This is shown in the diagram above)
- Complex Implementation
- Desynchronization Issues (Predicting multiple simultaneous events (e.g., player movement + object interaction) can get tricky, especially in fast-paced games.)
Safety regarding Remote-Events and Remote-Functions
This task is much more simpler so I’m just going to link sources to view.
-
Best way to protect Remote-Events against exploiters? (Devforum Post)
- Remote Functions are not Safe (Suphi Kaner)
- All Use Cases for Unreliable-Remote-Events (ByteBlox)
Although Roblox themselves have improved their exploit detection systems, so this isn’t much to worry about anymore.
MOST OF THIS POST WAS TO BRING UNDERSTANDING, IF YOUR WILLING TO JUST COPY AND PASTE LARGE PROJECTS/TASKS DONT EXPECT YOUR SELF TO GO FAR
If you feel this is a tedious task at your level, some genius made a System called ChickyNoid by MrChickenRocket, which does this all and more for you.
I hope this had given you an idea on what you could do. Here are some more of the sources I’ve used for my Research, this will give you some deeper understanding, I also suggest you search for more about this.
- Client-Side Prediction and Server Reconciliation
- What is Client Side Prediction
- Multiplayer Networking Challenges
- What is “Server Authoritative”