Hello, for a projectile weapon there are many ways to do it. For example you can rely on roblox’s physcis engine and then use the .Touched event to see when the projectile hits something. You should read up on vector forces if your interested in this approach. Additionally, I would recommend creating the projectile on the server and client. On the client immediatly spawn the projectile, this projectile is just for visuals. On the server you can make a projectile and adjust it based on the ping amount of the player, make it transparent and use it for detecting the collisions and doing the damage.
.Touched can get get bad for high speed projectiles however this is less of an issue then people make it to be.
However the main problem I would say with the above approach is making a projectile on server and client is hard to sync accuratly using roblox’s physcis.
An other way, is to use raycasting and not use roblox physcis at all. You would simulate the projectile each frame and raycast to the new position to figure out any collisions, you don’t have to use raycasting, you could implement custom sweeping but I would say raycasting is the easiest solution and works for most small projectiles, for bigger onces you could even shoot multiple rays
Here is a simple example to get you started
local Speed = 100
local Params = OverlapParams.new()
local PART = workspace.projectile
Params.FilterDescendantsInstances = {PART}
game:GetService('RunService').Heartbeat:Connect(function(TimeFromPreviousFrame)
local NewPosition = Part.Position + Vector3.yAxis * TimeFromPreviousFrame * Speed
local Hit = workspace:Raycast(OldPosition, (NewPosition - OldPosition), Part)
if Hit then
-- do something
else
PART.Position = NewPosition
end
end)
Hitscan is really simple, just shoot a ray where the the mouse is hitting, you can use mouse.Hit.Position, ect. Send this hit position to the server and the client shoot position, make sure the server does some validation to see if the hit position and client shoot position is plausaible to prevent exploiters, and shoot a ray on the server from the Player start position to the hit position to see what what was hit.