Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make this rope constraint replicate to the server and other clients properly?

I've created a system that constructs a rope constraint between a player and another player once a tool is clicked on them. The person who uses the tool can then drag the other player around. F.E is turned on. I've used remote events to make it compatible, and it works in play solo. However on a local server of two players, it does not. For both Player1 (who used the tool) and the server, once the rope constraint is made, it fails to pull Player2 along with it and the constraint just gets longer and longer despite the length being set max at 10. However on Player 2's screen, he is getting pulled along by the RopeConstraint like he's supposed to. When the tool is unequipped, for Player1 and the server, Player 2 then just simply teleports next to Player 1. Despite my efforts, I'm out of ideas.

Local Script


Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
debounce = false
local con
anim = game.ReplicatedStorage.Caught
--Door1 = game.Workspace.Door1
--TP1 = game.Workspace.TP1
repeat wait() until script.Parent.GotSomeon
GotSomeone = script.Parent.GotSomeon
KD = mouse.KeyDown

script.Parent.Equipped:Connect(function()
	con = mouse.Button1Down:Connect(function()
		if mouse.Target ~= nil then
			local Hit = mouse.Target
			print("hi")
				if Hit.Name == ("Torso") or Hit.Name == ("Head") or Hit.Name == ("Left Leg") or Hit.Name == ("Right Leg") or Hit.Name == ("HumanoidRootPart") or Hit.Name == ("Left Arm") or Hit.Name == ("Right Arm") then
					print("It's a Player")
					local Jailed = Hit.Parent
					local Jailed2 = Jailed:FindFirstChild("HumanoidRootPart")
					script.Parent.RemoteEvent:FireServer(mouse,anim,Jailed,Jailed2,Hit,GotSomeone,KD)
					

script.Parent.Unequipped:Connect(function()
	if con then
		con:Disconnect()
		con = nil

    end

end)

		end		end
end) end)

Script

script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player,mouse,anim,Jailed,Jailed2,Hit,GotSomeone,KD)
	print("Fired")
	local Jailed1 = Instance.new("Part",game.Workspace)
	Jailed1.Transparency = 1
	Jailed1.CanCollide = false
	Jailed1.Anchored = true
	local attachmentB = Instance.new("Attachment",Jailed2)
	local attachmentA = Instance.new("Attachment",Jailed1)
	attachmentA.Position = Vector3.new(1,-0.7,0.3)
	attachmentB.Position = Vector3.new(0,0,0.3)
				
	print("Got him")
	GotSomeone = true
	local ropeConstraint = Instance.new("RopeConstraint",game.Workspace)
	ropeConstraint.Attachment0 = attachmentA
	ropeConstraint.Attachment1 = attachmentB
	ropeConstraint.Length = 10
	ropeConstraint.Visible = true
	ropeConstraint.Color = BrickColor.Black()
	ropeConstraint.Thickness = 0.2
	ropeConstraint.Restitution = 0.5
	local caught = Jailed.Humanoid:LoadAnimation(anim)
	caught:Play()
		


local leCoroutine = coroutine.create(function()	
	while true do
		Jailed1.CFrame = Player.Character.Tool.Handle.CFrame
		wait()
		if script.Parent.Parent ~= Player.Character then
			break
		
		
		end
	end
end)

	
	coroutine.resume(leCoroutine)

 
					
	
	script.Parent.Unequipped:Connect(function()
		wait(.1)
		ropeConstraint:Destroy()
		attachmentA:Destroy()
		attachmentB:Destroy()
		caught:Stop()
		GotSomeone = false
	end)
	
end)

1 answer

Well because the client controls the player still, my suggestion would be to do Humanoid.PlatformStand = true on the person being dragged.

This discussion is preserved as it was. New answers, comments, and votes are closed.