Physical bullet not spawning correctly

The problem I am having is that the bullet spawns incorrectly when the player moves. I have tried editing the CFrame frame by frame and it is still laggy.

local function CreateBullet()
	
	local Bullet = Instance.new('Part', MainModule.Workspace)
	Bullet.Name = MainModule.LocalPlayer.Name .. '-Bullet'
	Bullet.CanCollide = false
	Bullet.Shape = Enum.PartType.Block
	Bullet.Transparency = 0
	Bullet.Size = Vector3.new(1, 1, 1)
	
	local MuzzleWorldCFrame = MainModule.WeaponInHand.Handle.Muzzle.WorldCFrame
	local OriginalPosition = MainModule.WeaponInHand.Handle.Muzzle.WorldPosition
	
	local Direction = MuzzleWorldCFrame.LookVector + (MuzzleWorldCFrame.UpVector * (((MainModule.WeaponData.BulletDrop * MainModule.WeaponData.CurrentDistance/4)/MainModule.WeaponData.MuzzleVelocity))/2)
	local BulletCF = CFrame.new(OriginalPosition, MuzzleWorldCFrame.LookVector)

	local BulletMass = Bullet:GetMass()
	local BulletForce = Vector3.new(0, BulletMass * (196.2) - (MainModule.WeaponData.BulletDrop) * (196.2), 0)
	local BodyForce = Instance.new("BodyForce",Bullet)
	
	Bullet.CFrame = BulletCF
	Bullet:ApplyImpulse(Direction  * MainModule.WeaponData.MuzzleVelocity * TableModule.ModuleTable.MuzzleVelocity)
	BodyForce.Force = BulletForce
	
end

Seems to be the direction of the bullet, I tried to change the direction and it seems to be the same.

the bullet is always going to fall behind because you are moving.
only way to make it correct is add the velocity of the player to the origin of the bullet (where its going to spawn) before you spawn the bullet, and even then it still doesnt work 100% of the time

also i suggest you use FastCast, it is very fast and very good at projectiles. plus it doesnt do bullets through physics which can cause a lot of lag (like what you do)

Thank you for your response,

I will look at the Fastcast even though it seems very complicated, but anyway how would you apply the player velocity to the origin of the bullet? At the moment I have tried to add the speed of the root part to it.

convert the velocity of the root part to be local on the bullet’s origin cframe
then times the origin cframe by the velocity local cframe (Cframe.new(localVelocity))

But when you apply the impulse to the bullet (Bullet:ApplyImpulse) it also changes the direction depending on the speed of the player (even changing the origin of the bullet). How can I fix that?