Help with Projectiles

I’m have made a projectile that runs on the client, but I have ran into an issue as I don’t know how to verify that the damage is legal, I did this for a hitscan weapon with a simple raycast but I have no idea how to write the code for the projectile weapon to see if the damage should be allowed to apply.

I’m using Fastcast for the projectiles if that helps.

my code for the hitscan weapon:

If anyone has any suggestions please help lol.

I’m sorry if I’m unclear but I’m kind of terrible at explaining things, if you need me to elaborate don’t hesitate to let me know.

To cause damage on the Server you need to fire the weapon twice.

  1. On the Client
  2. On the Server

You can use the same script for both, just cut and paste the contents of the LocalScript into a Server script. Keep them both inside the gun.

Add a RemoteEvent inside the gun. Now change up your Server script to listen for the RemoteEvent as a call to fire instead of a mouse click. Something like so:

RemoteEvent.OnServerEvent:Connect(function (player, event, item, mouseHitPosition)
			
	if player ~= Player then return end
	if event ~= "FireWeapon" then return end
	if item ~= "MyGunName" then return end

	-- remaning code

Also, remove any bullet rendering info from your Server script so the bullet is not rendered on the server, just the actual shot.

Now you have to send that same shot to all clients, then render the shot on each client machine for everyone in the game to see the projectiles.

i already have the projectile done, and i already have a remoteevent on the server. i dont want to do the Hit detection on the server though because of latency, for the client it may appear like you hit someone but then the server might not have that person in the same location as the client which would cause the hit detection to look wrong for the client, this is why i have decided to run the Hit detection on the client and just do a simple sanity check on the server to make sure that the clients damage request is legitimate.

Doing the hit detection on the client opens you up to hacking.

that’s why I need a sanity check on the server, I have already made the client and sanity check for my HitScan weapons and that works fine, but I don’t know how I would go about doing sanity check for a projectile.

I am not certain how you can do a sanity check without the shot origin and impact.

Sorry if i didnt clarify enough but all of the structure for the server-client communication is already set up, the server knows where the shot originated, Where the shot Hit, the part the Shot Hit and some more