I have made a projectile system and here is how it works.
A client fires the gun, a bullet is then made LOCALLY on the client that fired it. The client then fires a remote event with the root position of the bullet, and the target position of the bullet to the server. The server then sends those cframes down to every client so they can also render the bullet. I have successfully made this to where other players can see the bullets that another player fires, but I have no clue how to make them deal damage. I have tried to put a localscript in the bullet that fires a remote event whenever it touches a player, so the server can deal damage, but that did not work. All help is appreciated. Thank you.
--Server
local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("FireEvent")
RE.OnServerEvent:Connect(function(player, targetPos, rootPos)
local initialPlayer = player
RE:FireAllClients(initialPlayer, targetPos, rootPos)
end)
--Client
local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("FireEvent")
local player = game.Players.LocalPlayer
local bul = RS:WaitForChild("Bullet")
RE.OnClientEvent:Connect(function(initialPlayer, targetPos, rootPos)
if initialPlayer ~= player then
local clone = bul:Clone()
clone.Parent = game.Workspace
clone.CFrame = rootPos
clone.CFrame = CFrame.new(clone.Position, targetPos)
clone.BodyVelocity.velocity = clone.CFrame.LookVector * 120
end
end)
--Inside of the tool that fires the projectile
local db = false
local handle = script.Parent:WaitForChild("Handle")
local RS = game:GetService("ReplicatedStorage")
local bul = RS:WaitForChild("Bullet")
local RE = RS:WaitForChild("FireEvent")
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
if db == false then
db = true
local char = script.Parent.Parent
local mH = mouse.Hit
local rootPos = script.Parent.Handle.CFrame * CFrame.new(char.UpperTorso.CFrame.LookVector * 2)
local targetPos = mH.p
RE:FireServer(targetPos, rootPos)
local clone = bul:Clone()
clone.Parent = game.Workspace
clone.CFrame = rootPos
clone.CFrame = CFrame.new(clone.Position, mH.p)
clone.BodyVelocity.velocity = clone.CFrame.LookVector * 120
wait(0.3)
db = false
end
end)
end)

7 comments
the blast must have an hit then hit finds a player that has a humanoid, and then hit damages that using :TakeDamage(HEALTHNUMBER)
I tried that but it did nothing to the other player. I put the hit detection script inside the bullet.
this is why u shouldnt do stuff like this
u try to make it faster and u end up with a lot more crap then u started with
also u dont need to send the root pos u could get that from the player's character
every bit counts uk
also also, what ur trying to do is practically what the server does when u spawn a part so there is really not much difference, tho its does make it more unbalanced for ppl with faster internet cus they get to see the bullet coming first