Having trouble with raycasting and positioning

I’m trying to make a cuff system that adjusts a weld offset when the ‘cuffed’ player gets close to an object. After messing around for about 4 hours I got something working, however it can move the cuffed player behind the cuffing player. What should I do to block that?

localscript:

local function onRenderStepped()
	local Weld = HRP:FindFirstChild('CuffWeld')
	if not Weld then
		return
	end
	
	local DetaineeHRP = Weld.Part1
	local rayParams = RaycastParams.new()
	rayParams.FilterType = Enum.RaycastFilterType.Include
	rayParams.FilterDescendantsInstances = {workspace}
	
	local rayResult = workspace:Raycast(DetaineeHRP.Position,DetaineeHRP.CFrame.LookVector * 2,rayParams)
	if rayResult then
		if Players:GetPlayerFromCharacter(rayResult.Instance.Parent) == nil then
			RepStorage.Remotes.Events.updateWeldOffset:FireServer(rayResult.Distance,Weld)
		end
	end
end

ServerScript

local function updateWeldOffset(Player,Distance,Weld)
	if not Player.Character.HumanoidRootPart:FindFirstChild('CuffWeld') then
		Player:Kick('Reason: Exploiting | Exploit: Script executor')
		return
	end
	local deltaNum = 1.5 - Distance
	print(Player.Character.HumanoidRootPart.Position - Weld.Part1.Position)
	Weld.C1 = Weld.C1 * CFrame.new(Vector3.new(0,0,-deltaNum))
end

Video of what happens: