So apparently, when i was testing out. Some of the bullets didnt hit the target. (like i was placing my mouse at the torso and it just goes backwards).
Code for the raycasts:
local origin = player.Character.Head.Position
local currentline = (hitpos - origin)
local direction = currentline.Unit
local distance = currentline.Magnitude * 1.5
distance = 9999
local ray = Ray.new(origin,direction * (distance + 3))
local hit,Position,normal = workspace:FindPartOnRayWithIgnoreList(ray,{player.Character,game.Workspace.Barriers})
Ok i figured out something. https://i.gyazo.com/038766f8e3d5a425dc4f85a9d6013e72.mp4
The red part is where the raycast hitted. Im not pretty sure what it hitted but turns out some of them hit and it is quite nearly behind the player
Oh wait I figured it out!
The mouse.Hit.p is from the client side and will detect anything on server or client. Im pretty sure I forgot to add a targetfilter. So you must either add a target filter OR a raycast with ignorelist.