Having looked at their code, problem is using mouse doesn’t take into account collision groups. When shooting at say a forcefield, the mouse.Hit returns that forcefield, but the bullet needs to pass that, and so the bullet gets shot at a weird angle. So I can’t use Mouse.Hit for that reason
local Mouse = Player:GetMouse()
local directionalCF = CFrame.new(Vector3.new(), (Mouse.Hit.Position - firePoint).Unit)
local Direction = (directionalCF * CFrame.fromOrientation(-0.05, 0, 0) * CFrame.fromOrientation(0, 0, 0)).LookVector
But if you look when I shoot through a forcefield, the bullet goes askew, This was one of the reasons I resorted to camera, as I could ignore forcefields.
Can see when shooting at parts, it’s great, but when shooting through the field, your bullet goes off skew
EDIT Hold on gif glitched, lemme get another vid
As you can see, when shooting (not through forcefield part) the bulelts line up with my scope (they not perfectly centre due to gravity) but when Ishoot through the forcefield, they are wayyy off
As the above problem, it works great on normal parts, but when shooting through forcefields, it goes way off. This is due to Mouse.Hit not taking into account collision groups, and thus it returns the position on the forcefield, when it should return the position beyond that. Thus, I can’t use Mouse.Hit.Position AT ALL
i don’t think the issue is the raycast. you seem to be shooting the bullet from the barrel, but raycasting from the camera. Meaning that the bullet will follow the raycast of the camera, but be positioned to the barrel of the gun.
What i’d reccomend you to do is to ffirst raycast from the camera, take the position it hit, and then to take the normalised vector from the position where it hit, to the position where the barrel is (HitPos-BarrelPos).normalised.
Then, you can use that normalised vector as the direction the bullet should travel.
This seemed to work well in most cases! Small problem is the ray returns at times? The ray should NEVER return nil, and even if you aim into space, it should still shoot
local HitRaycast = workspace:Raycast(
UnitRay.Origin,
UnitRay.Direction * 10000,
CastParams
)
local Direction = (HitRaycast.Position - FirePoint).Unit