Gun system raycast issue

  1. What do you want to achieve?
    Working gun system without any RayCast issues.
  2. What is the issue?
    When you’re close to the character, the bullet goes up.
    https://i.gyazo.com/02cdc2a3b8e342a1f731f5e5f9fa16b0.mp4
  3. What solutions have you tried so far?
    the only way I can shoot without any issues is when I’m a little bit far away from the character. (happens with other objects too)

Could you share your code with us? There isn’t really anything anyone can do without it…

I had this issue when my gun parts had CanQuery enabled. but I can’t disable the head’s CanQuery option.

local function CastRay(StartPos,Direction,Length)
    local Hit,EndPos = game.Workspace:FindPartOnRay(Ray.new(StartPos,Direction * Length))
    if Hit then
        if (not Tool.Parent or Hit:IsDescendantOf(Tool.Parent)) or Hit.Transparency > 0.9 then
            return CastRay(EndPos + (Direction * 0.01),Direction,Length - ((StartPos - EndPos).magnitude))
        end
    end

    return EndPos
end

Disable bullet part CanQuery option so then your raycasting wont do like that