I am shooting away from the mouse hit

So basically like u will see in this clip, when I stand still my shots are accurate, but when I am shooting while moving, my shots become offset.
robloxapp-20201011-1708092.wmv (2.9 MB)
Important parts of scripts:
1st script:

part.Velocity = -shootP.CFrame.upVector * speed -- basically just saying I want to shoot forward 

2nd script

game:GetService("RunService").RenderStepped:Connect(function()
	local dif = (root.CFrame.p - ms.Hit.p) 
	local look = (root.CFrame.upVector)
	local angle = math.acos((dif:Dot(look) / dif.Magnitude * look.Magnitude))
	waist.C0 = defPos * cf.Angles(angle - math.pi / 2, 0, 0)
	local direction = (ms.Hit.p - root.Position) * v3.new(1, 0, 1)
	root.CFrame = cf.new(root.Position, root.Position + direction)
end)

Well anyways for the matter of context I will add here fully written scripts:

------- FOR MOVEMENT ---------------
local plr =  game:GetService("Players").LocalPlayer
local ms = plr:GetMouse()
local waist = plr.Character:FindFirstChild("Waist", true)
local defPos = waist.C0
local root = plr.Character:FindFirstChild("HumanoidRootPart")
local torso = plr.Character:FindFirstChild("UpperTorso")
ms.TargetFilter = plr
ms.TargetFilter = game.Workspace.Gun
local cf, v3 = CFrame, Vector3

game:GetService("RunService").RenderStepped:Connect(function()
	local dif = (root.CFrame.p - ms.Hit.p) 
	local look = (root.CFrame.upVector)
	local angle = math.acos((dif:Dot(look) / dif.Magnitude * look.Magnitude))
	waist.C0 = defPos * cf.Angles(angle - math.pi / 2, 0, 0)
	local direction = (ms.Hit.p - root.Position) * v3.new(1, 0, 1)
	root.CFrame = cf.new(root.Position, root.Position + direction)
end)
------- HANDLES SHOOTING ---------------
wait(2)
local plr = game:GetService("Players").LocalPlayer
local rayRemote = game:GetService("ReplicatedStorage"):WaitForChild("RayRemote")
local mouse = plr:GetMouse()
local cooldown = false
local blocklist = game.Workspace.TerrainEffects:GetChildren()

mouse.Button1Up:Connect(function()
	local gun = plr.Character:FindFirstChild("Gun")
	if gun then
		local shootP = gun.ShootPart
		local myRay = Ray.new(shootP.Position, (mouse.Hit.p - shootP.Position).Unit * 500)
		local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(myRay, {plr.Character, gun})
		
		local antiGravity = 0.8 -- lower numbers means lower gravity, bigger arch
		local speed = 1000 -- speed of the bullet
		
		local part = game:GetService("ReplicatedStorage").Bullet:Clone()
		part.Parent = game.Workspace
		part.CFrame = shootP.CFrame
		part.Massless = true
		part.CanCollide = false
		
		local bf = Instance.new("BodyForce")
		bf.Force = Vector3.new(0, workspace.Gravity * part:GetMass() * antiGravity, 0)
		bf.Parent = part
		local a0 = Instance.new("Attachment", part)
		a0.Position = Vector3.new(0.1, 0, 0)
		local a1 = Instance.new("Attachment", part)
		a1.Position = Vector3.new(-0.1, 0, 0)
		local trail = Instance.new("Trail", part)
		trail.Attachment0 = a0
		trail.Attachment1 = a1
		trail.FaceCamera = true
		trail.Transparency = NumberSequence.new({
			NumberSequenceKeypoint.new(0, 0),
			NumberSequenceKeypoint.new(1, 1)
		})
		trail.Lifetime = 0.1
		part.Velocity = -shootP.CFrame.upVector * speed
		
		local mistake = false
		part.Touched:Connect(function(hit)
			for i, v in pairs(blocklist) do
				if v == hit then
					mistake = true
					break
				end
			end
			if hit == gun or hit == shootP or hit.Parent:FindFirstChild("Humanoid") == nil or hit.Parent.Name == "Character" then
				print("mistake")
				mistake = true
			end
			if mistake == true then
				mistake = false
			else
				mistake = false
				part:Destroy()
				print("hit")
				rayRemote:FireServer(hit.Parent)
			end
		end) 
	end	
end)

Any help would be apriciated