All of the scripts are correct but it won't shoot for some reason.I have tried fixing it didn't help.
Gun main: --Made by: Hirez33 -- -- November 11 2018 --[[ This script manages the raycasting of the gun --]] --Variables local remote = game.ReplicatedStorage:WaitForChild("Remote"):WaitForChild("GunEvent") --Main remote.OnClientEvent:connect(function (player, barrelPos, mousePos) local ray = Ray.new(barrelPos,(barrelPos - mousePos).unit * 300) local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true) local dist = (barrelPos - mousePos).magnitude if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(10) end end remote:FireAllClients(player, part, position, barrelPos) end) Local script: -- Made by: Hirez33 -- -- November 11 2018 -- [[ Local script in charge of out gun ;) ]]-- -- Variables local gun = script.Parent local remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("GunEvent") --Main gun.Equipped:connect(function (mouse) mouse.Button1Down:connect(function () remote:FireServer(gun.Barrel.CFrame.p, mouse.Hit.p) end) end) BulletGenerate: --Made by Hirez33 -- -- November 11 2018 --[[ This script will generate the bullet for the player to see --]] --Variable local remote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("GunEvent") --Main remote.OnClientEvent:connect(function (player, part, position, dist, barrelPos) local bullet = Instance.new("Part") bullet.Anchored = true bullet.CanCollide = false bullet.BrickColor = player.TeamColor bullet.Material = "Neon" bullet.TopSurface = "Smooth" bullet.BottomSurface = "Smooth" bullet.Size = Vector3.new(0.3,0.3,dist) bullet.CFrame = CFrame.new(barrelPos, position) * CFrame.new(0,0 -dist/2) bullet.Parent = game.Workspace game.Debris:AddItem(bullet,0.1) end)
It's not working because when you subtract from the position of the barrel rather then subtracting from the mouse position, you get a position that instead would become the position of the barrel, subtracted by the mouse, meaning that it's only gonna be going from the barrel, and not in front.
Also when you fire all clients, it has to be from the server, not the client. It doesn't make sense to fire all clients when you are firing from the client its self.
Also, you want to fire the server with the correct arguments you have already.