RopeConstraint freezes one player

I’m tethering two players using a RopeConstraint + Beam, but one player gets stuck and can’t move on the client. On the server they seem to move somewhat (they get dragged by the other player but they still can’t move), but locally they’re frozen. (Replication issue?) No errors.

Here’s the rope script:

local Players = game:GetService("Players")

local function createAttachment(character)
	local hrp = character:WaitForChild("HumanoidRootPart", 3)
	if not hrp then return nil end

	local att = hrp:FindFirstChild("RootAttachment")
	if not att then
		att = Instance.new("Attachment")
		att.Name = "RootAttachment"
		att.Parent = hrp
	end

	hrp.Massless = false

	return att
end

local function attachRope(player1, player2)
	local char1, char2 = player1.Character, player2.Character
	if not (char1 and char2) then return end

	local att1 = createAttachment(char1)
	local att2 = createAttachment(char2)
	if not (att1 and att2) then return end

	local rope = Instance.new("RopeConstraint")
	rope.Visible = false
	rope.Attachment0 = att1
	rope.Attachment1 = att2
	rope.Length = 25
	rope.Restitution = 0.2
	rope.Thickness = 0.1
	rope.Parent = att1.Parent

	local beam = Instance.new("Beam")
	beam.Attachment0 = att1
	beam.Attachment1 = att2
	beam.Width0 = 0.2
	beam.Width1 = 0.2
	beam.Color = ColorSequence.new(Color3.fromRGB(200, 150, 50))
	beam.FaceCamera = true
	beam.Parent = att1.Parent
end

local function tryAttachPlayer(player)
	local mateName = player:FindFirstChild("PrivateValues") and player.PrivateValues:FindFirstChild("Mate")
	if not (mateName and mateName.Value ~= "") then return end

	local matePlayer = Players:FindFirstChild(mateName.Value)
	if not matePlayer then return end

	if not matePlayer.Character then matePlayer.CharacterAdded:Wait() end
	if not player.Character then player.CharacterAdded:Wait() end

	if not (player.Character:FindFirstChild("HumanoidRootPart") and matePlayer.Character:FindFirstChild("HumanoidRootPart")) then
		player.Character:WaitForChild("HumanoidRootPart")
		matePlayer.Character:WaitForChild("HumanoidRootPart")
	end

	attachRope(player, matePlayer)
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		task.wait(0.5)
		tryAttachPlayer(player)
	end)
end)

No anchored parts, tried changing rope length, attachments are in HumanoidRootPart, tried parrenting to workspace. Made sure HRP isn’t massless. Tried setting NetworkOwnership to the server.

Any ideas? Could it be a replication issue?

2 Likes

RopeConstraints rely on a NetworkOwnership, you should run :SetNetworkOwnershipAuto() on both players RootPart

You also dont have to make a new attachment, you can use the Root’s

2 Likes

Applied these changes and still same issue.

Fixed it by separating the visual and physical parts of the rope.

The beam (visual) is created and managed by the server so all clients see the effect.
The RopeConstraint (physics) is created in a LocalScript inside StarterCharacterScripts, so it only affects the local player and avoids replication issues or network ownership bugs.

(issue is back after testing)

Question – when you switched the RopeConstraint code to the client, I’m assuming that Player1 would get limited / dragged by the movement of Player2 (on Player1’s client) and the same with Player2 to Player1 (on Player2’s client)?

And this replicated server-sided RopeConstraint behavior well enough? That’s a really interesting approach… cool solution.

1 Like

Guess what, while testing I discovered a logic issue in the code that prevented the rope from being created. I fixed it, but now the problem has returned.