Hi guys, using a script, I'm able to deal damage to NPC without firing to the server. I also know that to damage an NPC with a LocalScript, I will need to fire to the server. What I want to know is should i go through the trouble of using a localscript and firing to the server or just use a normal script for my melee weapon? Thanks in advance.
Almost always you will want to handle user input from the client in a LocalScript
, and fire the server when necessary. You should use either a Script
or a module server-side along with a LocalScript
.
The server cannot see a player's mouse, because the mouse is local to the player.
I encourage you to give immediate visual feedback to the client. For example, let's say we have a lasergun.
Bad approach:
Player clicks to fire the wepaon.
Weapon tells server, "hey, I clicked."
Server creates laser part and does damage calculations.
This will look awful. The player that fired the weapon will see a visible and gross delay in the part being created.
Good approach:
Player clicks to fire the weapon.
Client that fires tells the server, "hey, I fired."
Client that fired does calculations for the laser part locally. (And possibly damage calculations too for display purposes)
Client that fired creates laser.
Server does authoritative damage calculations.
Server fires remotes to all players that were not the original firing player.
Each client receives the remote fire and creates the laser part on their client.
The same approach can be applied to other types of tools.
Relevant article:
http://wiki.roblox.com/index.php?title=Fighting_Lag