Why is the attachment lines not running

I want to achieve a rope that attaches to 2 players. The line keeps stopping on is where I do my Attatchments.

script.Parent.Players.OnServerEvent:Connect(function(player, Text)
	local part2 = game.Workspace:WaitForChild(Text).HumanoidRootPart
	local part1 = game.Workspace:WaitForChild(player.Name).HumanoidRootPart
	local w = Instance.new("RopeConstraint")
	w.Parent = part2
	w.Name = "ROPEDRAG"
	w.Attachment1 = part2
	w.Attachment0 = part1
end)
local att0 = Instance.new("Attachment")
att0.Parent = part1

rope.attachment0 = att0

Repeat for attachment 1 and the other part.

Try This

script.Parent.Players.OnServerEvent:Connect(function(player, Text)
	local part2 = game.Workspace:FindFirstChild(Text)
	local part1 = game.Workspace:FindFirstChild(player.Name)
	
	if part2 and part2:IsA("BasePart") and part1 and part1:IsA("BasePart") then
		local w = Instance.new("RopeConstraint")
		w.Parent = part2
		w.Name = "ROPEDRAG"
		w.Attachment1 = part2
		w.Attachment0 = part1
		print("Rope attached between", part1.Parent.Name, "and", part2.Parent.Name)
	else
		print("Invalid parts for rope attachment")
	end
end)