Help with Placement System

Hello Everyone! I have a problem with my Placement System. I want to make a Part Connection when a player is looking at the part that makes the connection. I’ve tried to make something, but It’s not working and I don’t know why. (sorry for that bad explanation, I’ve made screenshots to show you what I mean about part connection.)

EDIT: I don’t have any errors in output. And it’s not printing working or working2, only working3

What solutions have you tried so far? I didn’t find anything in DevForum or else.

Here are screenshots what I mean about Part that Connects:


As you see, when for example Mouse is Targeting that parts it will connect pallets.

Here is LocalScript (not full):

                local clientModel = models[frame.Name].PrimaryPart:Clone()
				clientModel.Parent = workspace
				clientModel.Color = Color3.fromRGB(86, 162, 39)
				clientModel.Material = Enum.Material.ForceField
				clientModel.CanCollide = false
				
				local startCF = CFrame.new(0, -2, -15)
				clientModel.CFrame = hrp.CFrame:ToWorldSpace(startCF)
				buildingFrame.modal.Modal = false
				runService.RenderStepped:Connect(function()
					local modelClone
					local target = mouse.Target
					if target and (target.Parent.Name == 'Connections' or target.Name == 'Point') then
						print('working')
						if not modelClone then
							modelClone = clientModel.Root:Clone()
							modelClone.Color = Color3.fromRGB(255, 255, 255)
							modelClone.Material = Enum.Material.ForceField
							modelClone.Parent = workspace
							
							clientModel.Transparency = 1
							warn('working2')
						end
						if target ~= clientModel then
							clientModel.CFrame = target.CFrame * CFrame.new(0, 0, 4) * CFrame.Angles(0, -math.pi/2, 0)
						end
					else
						if modelClone then
							modelClone:Destroy()
							modelClone = nil
							clientModel.Transparency = 0
						end
						local mouseRay = mouse.UnitRay
						local ray = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000)
						local ignoreTable = {clientModel, char}
						local hit, pos = workspace:FindPartOnRayWithIgnoreList(ray, ignoreTable)
						if ray and hit then
							print('working3')
							if (hit:IsA('Terrain') or hit.Name:lower() == 'terrain') or hit:IsA('BasePart') then
								if (hrp.Position - clientModel.Position).Magnitude < maxDistance then
									goodToPlace = true; clientModel.Color = Color3.fromRGB(86, 162, 39) else
									goodToPlace = false; clientModel.Color = Color3.fromRGB(255, 0, 0) 
								end
								local anglesCF = CFrame.Angles(math.rad(xOr), math.rad(yOr), math.rad(zOr))
								local newCF = CFrame.new(pos.X, pos.Y + yOffset, pos.Z)
								clientModel.CFrame = newCF * anglesCF
							end
						end
					end
				end)

Here is ServerScript:

local rs = game:GetService("ReplicatedStorage")
local place = rs.Remotes.Events:FindFirstChild('Place')
local models = rs:FindFirstChild('Storage')

place.OnServerEvent:Connect(function(player, modelName, modelCF)
	local realModel = models:FindFirstChild(modelName):Clone()
	
	for i,v in pairs(realModel.Connections:GetChildren()) do
		if v:IsA('BasePart') then
			local weldConstraint = Instance.new('WeldConstraint', realModel.PrimaryPart)
			weldConstraint.Part0 = realModel.PrimaryPart
			weldConstraint.Part1 = v
		end
	end
	if realModel then
		realModel.Root.CFrame = modelCF
		realModel.Root.Anchored = true
		realModel.Parent = workspace
	end
end)

If someone will help me, it would be really appreciated! Thanks.