Issue with Loockvector as player is moving

Ive created a standard Raycast gun system which forms the rays on the client and does damage on the server, however, and issue arrises when the player is moving in a linear fashion or the mouse remains in the same position, the raycasts are casted at a very odd angle, not at all equal to the look vector, despite being directly attributed to it. below is the client sided script (only the main function) + video (THIS ISSUE DOES NOT EXIST WHEN THE PLAYER IS STATIONARY)

local function shoot()
	if db == false and canShoot == true  and CurrentAmmo > 0 then
		CurrentAmmo -= 1
		db = true
		t.Click:FireServer(configs.Type)
		
		local shootOrigin = player.Character.HumanoidRootPart.CFrame.Position
		local direction = (player.Character.HumanoidRootPart.CFrame.LookVector * configs.Range)
		
		local size1 = Vector3.new(0.5,1,0.5)
		local params = RaycastParams.new()
		params.FilterDescendantsInstances = {script.Parent,script.Parent.Parent}
		params.FilterType = Enum.RaycastFilterType.Blacklist
		
		local raycast = workspace:Raycast(shootOrigin,direction,params)
		local intersection = raycast and raycast.Position or shootOrigin + direction
		local distance = (shootOrigin - intersection).Magnitude

		local bullet_clone = Instance.new("Part")
		bullet_clone.Anchored = true
		bullet_clone.CanQuery = false
		bullet_clone.CanCollide = false
		bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
		bullet_clone.CFrame = CFrame.new(shootOrigin, intersection)*CFrame.new(0, 0, -distance/2)
		bullet_clone.Parent = game.Workspace
		if raycast then
			script.Parent.EffectHitEVent:FireServer(raycast.Position)
			if raycast.Instance.Name == "Crate" then
				EventsFolder.CratePunch:FireServer(raycast.Instance,configs.ObsticalDamage)
			else
			if raycast.Instance.Parent:FindFirstChild("Humanoid") then
				if raycast.Instance.Name == "Head" then
					ShootEvent:FireServer(raycast.Instance.Parent.Humanoid,raycast.Instance,true)
				elseif raycast.Instance.Name ~= "Head" then
					ShootEvent:FireServer(raycast.Instance.Parent.Humanoid,raycast.Instance,false)
				end
				end
			end
		end
		ShootEvent:FireServer()
		--
		wait(configs.Cooldown)
		db = false
	end
end

Just make raycasts on server and give them some player’s momentum.

It looks to me like you’re adding visualization parts on the server, where you’re sending the raycast hit point, but the server has an old position for your character when this RemoteEvent arrives, so what it draws is just a line from wherever you are on the server, to wherever your client said the bullet hit. Naturally this is not going to be correct because your avatar’s position replicates separately through property replication, so changes to avatar position are not in any way in sync with the raycast result. If you send the ray origin used for the Raycast to the server along with the resulting raycast.Position, it would not have this directional problem.