Problem with welding: handcuffs

Hello devforum, Im trying to make a pair of handcuffs but Im having some trouble:
When I arrest someone a pick him up it should look like this:
img1

And it actually looks like this sometimes.

Now, the problem it that sometimes the person who arrested the other player gets stuck in the ground for some reason. Its like if the other player was anchored, but he isnt. The arrested player can walk around and the player who should be taking him arround is stuck without being able to walk.
img2

This is the part of the script im using to weld it:

local holding
local thischar 
local otherchar
local weld

event2.OnServerEvent:Connect(function(plr, otherplr, weldv, tool)
	print("Received")
	thischar = plr.Character or plr.CharacterAdded:Wait()
	otherchar = otherplr.Character or otherplr.CharacterAdded:Wait()
	if holding == false or holding == nil then
		otherchar.HumanoidRootPart.CFrame = CFrame.new(thischar.RightHand.Position)
		weld = Instance.new("Weld", otherchar)
		weld.Part0 = tool.Handle
		weld.Part1 = otherchar.HumanoidRootPart
		weld.C0 = CFrame.new(0,0.5,-1)
		weldv.Value = weld
		holding = true
		thischar.Humanoid.JumpPower = 0
		otherchar.Humanoid.JumpPower = 0
		otherchar.HumanoidRootPart.CFrame = CFrame.new(thischar.RightHand.Position)
		thischar.HumanoidRootPart.CFrame = CFrame.new(thischar.HumanoidRootPart.Position) * Vector3.new(0, 5, 0)
	elseif holding == true then
		print("Gonna destroy")
		weldv.Value:Destroy()
		thischar.Humanoid.JumpPower = 50
		otherchar.Humanoid.JumpPower = 50
		holding = false
		otherchar.HumanoidRootPart.CFrame = CFrame.new(thischar.RightHand.Position)
	end
end)

I’d really appreciate some help!

Thanks for reading.

1 Like

Don’t use a weld constraint for handcuffs, attaching two players with any weld always leads to annoying issues from what I’ve seen, what you can do instead is either:

BodyGyro & BodyPosition (Or the constraints version since BodyGyro and BodyPos is legacy) or Constantly CFrame the humanoidrootpart (and anchor) of the player that is being handcuffed infront of the player handcuffing (just take the cframe of the player handcuffing the other player and offset it to be infront)

1 Like

Like this?

local holding
local thischar 
local otherchar
local weld

event2.OnServerEvent:Connect(function(plr, otherplr, weldv, tool)
	print("Received")
	thischar = plr.Character or plr.CharacterAdded:Wait()
	otherchar = otherplr.Character or otherplr.CharacterAdded:Wait()
	if holding == false or holding == nil then
		print("Gonna put")
		holding = true
	elseif holding == true then
		print("Gonna destroy")
		holding = false
	end
end)

while wait(0.05) do
	if holding == true then
		print("Holding")
		otherchar.HumanoidRootPart.Anchored = true
		otherchar.HumanoidRootPart.CFrame = CFrame.new(thischar.RightHand.Position)
	else
		otherchar.HumanoidRootPart.Anchored = false
		print("Not holding")
	end
end

Try using cframes instead and use run service.

1 Like

But the script works in the server.

Edit:

My bad, I was using renderstepped instead of stepped, sorry :sweat_smile:

Yeah this is serverside

game:GetService(“RunService”).Stepped:Connect(function()
end)

do your research before you respond.

1 Like

It’s possible you have RunningNoPhysics as the HumanoidStateType when you cuff the other player. This would normally yoink you into the ground. If you have the Running State, physics will be calculated and you shouldn’t go into the ground. Try forcing Running as you cuff the other player (you can do this with the :ChangeState() function inside the humanoid).

Does this help?

1 Like

Right now there are a couple problems, there is delay when moving the person, and the person doesnt face where the player faces for some reason. I have tried using

otherchar.HumanoidRootPart.CFrame = CFrame.new(toool.Handle.Position, toool.Handle.CFrame.LookVector)

but it doesnt work.
https://gyazo.com/b130f82e8eddeef6a5b8b4288068e15d

The problem is that when I set it to running it instantly sets to RunningNoPhysics again.

Edit:
I made this script to test it, and even with that look at the output:
image
Even with a really fast loop it only prints running one time

Script:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

while wait(0.0000000000001) do
	character.Humanoid:ChangeState(Enum.HumanoidStateType.Running)
	print(tostring(character.Humanoid:GetState()))
end

Second edit:
It actually works, but abit bugged because is changes from RunningNoPhysics and Running and vice versa all the time.
Is there any way of making it not change to RunningNoPhysics?