Looking for help on my C# code for spawning a bodyguard

You need to use the snowball entity position, not the player position, you shouldn’t even need a raycast or anything. I’m into Lua so I can write it in Lua but you’ll have to port it to C#.

local throwingEgg = false
local currentEggs, currentSpawns = {}, {}

SpawnModelAtPosition = function(model, pos)
  if not IsModelInCdimage(model) then print('Model not found in client cd image, returning'); return; end
  if not IsModelValid(model) then print('Model not valid for client, returning'); return; end
  while not HasModelLoaded(model) do RequestModel(model); Citizen.Wait(10); end
  table.insert(currentSpawns, CreatePed(2, model, pos, GetEntityHeading(PlayerPedId()), true, false))
end
  
Citizen.CreateThread(function()
  AddTextEntry('eggthing', 'Press ~INPUT_MP_TEXT_CHAT_TEAM~ to throw egg')
  while true do
    Citizen.Wait(0)
    local wep = GetSelectedPedWeapon(PlayerPedId())
    if wep and wep == `WEAPON_SNOWBALL` then
      DisplayHelpTextThisFrame('eggthing', false)
      if IsControlJustReleased(0, 246) or IsDisabledControlJustReleased(0, 246) then
        throwingEgg = not throwingEgg
        AddTextEntry('eggthing', 'Press ~INPUT_MP_TEXT_CHAT_TEAM~ to throw '..((throwingEgg and 'snowball') or 'egg'))
      end
      if throwingEgg then
        if IsPedShooting(PlayerPedId()) then
          currentEggs[GetClosestObjectOfType(GetEntityCoords(PlayerPedId()), 1.0, `w_ex_snowball`, false, false, false)] = GetEntityCoords(PlayerPedId())
        end
      end
      for k,v in pairs(currentEggs) do
        if DoesEntityExist(k) then
          currentEggs[k] = GetEntityCoords(k)
        else
          SpawnModelAtPosition(`a_c_chimp`, v+vector3(0.0, 0.0, 1.0))
          currentEggs[k] = nil
        end
      end
    end
  end
end)