I seem to be having another issue with one of my ranged weapon scripts. (Man, raycasting is hard…
)
Anyways- the issue here is that whenever a player fires with the weapon by holding down M1, they can still damage team members.
The problem though is that- whenever I try to fix the issue 1 of 2 things happen…
Players will never take damage
…or it’ll just go back to damaging everyone.
If anyone knows the solution, that would be greatly appreciated! 
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('RFFired')
local damage_amount = 8
local GRAVITY_ACCELERATION = workspace.Gravity
local Team = game.Teams
remoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
local bullet = Instance.new('Part')
bullet.Name = 'Bullet'
bullet.Parent = game.Workspace
bullet.Shape = Enum.PartType.Block
bullet.Transparency = 0.25
bullet.Material = "Neon"
bullet.Size = Vector3.new(0.35, 0.35, 0.35)
bullet.BrickColor = BrickColor.new('Electric blue')
bullet.CanCollide = false
local speed = 150
bullet.CFrame = CFrame.new(gunPos, mosPos)
bullet.Velocity = bullet.CFrame.lookVector * speed
local bodyForce = Instance.new('BodyForce', bullet)
bodyForce.Name = 'Antigravity'
bodyForce.Force = Vector3.new(0, bullet:GetMass() * GRAVITY_ACCELERATION, 0)
bullet.Touched:Connect(function(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
if humanoid and humanoid.Parent.Name ~= player.Name then
if humanoid.Health > 0 and humanoid.Health - damage_amount <= 0 then
player.leaderstats.KOs.Value += 1
end
humanoid:TakeDamage(damage_amount)
bullet:Destroy()
end
end)
game:GetService('Debris'):AddItem(bullet, 0.5)
end)