How to make the arms not face backwards after welding a tool?

Hi, I’ve just been working on my handcuff tool and got stuck on this weld thing for hours. The way I want the handcuff to work is that when I click on a player’s body part, it will weld the target player and the player will be CFramed to be in front of me (with a little distance).

I’ve got until this part, but I’m not sure position the target player to be in front of me.

--// SERVER SCRIPT
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local handcuffsEvent = Instance.new("RemoteEvent", ReplicatedStorage)
handcuffsEvent.Name = "handcuffsEvent"

handcuffsEvent.OnServerEvent:Connect(function(player, target, category)
	if category == "weld" then
		local myCFrame = workspace[player.Name].HumanoidRootPart.CFrame
		target.HumanoidRootPart.CFrame = myCFrame * CFrame.new(0, 0, -3)
		wait(.1)
		
	--	target.HumanoidRootPart.CFrame = CFrame.new(myCFrame + 10)
		local weld = Instance.new("Weld")
		weld.Part0 = workspace[player.Name].Handcuffs.Handle
		weld.Part1 = target.HumanoidRootPart
		weld.Name = "HandcuffsWeld"
		weld.Parent = workspace[player.Name].Handcuffs.Handle
--		weld.C0 = weld.C0 * CFrame.Angles(math.rad(180) , 0, 0) * CFrame.new(0,0,0)
		weld.C1 = weld.C1 * CFrame.Angles(0, 0, 0)
		weld.C0 = CFrame.Angles(math.rad(90),math.rad(90),math.rad(90))
		for i, v in pairs (target:GetChildren()) do
			
		end
	elseif category == "unweld" then
		
	end
end)
 

  

With the current script, this is what happens.

For some reason, after I weld, my arm always faces backwards not forwards. How to fix this?

Any help is appreciated, thanks.

2 Likes

Hi,

Perhaps you should look at periodically moving the player’s character? For example, every 0.1 seconds the player’s character is teleported in front of your character. This can be done by the CFrame:ToWorldSpace() function pretty easily and is what I use for my detain system.

Essentially it takes the CFrame of the target’s head and moves it to 5 studs in front of your head. Changing a character head CFrame essentially teleports the player. The great thing about ToWorldSpace() is that the parameter is simple a CFrame value that works relative to the target.

It might not be the most efficient way of solving your problem, but it works pretty seamlessly for me. For more information check out:

Hope this helps,
-Tom :slight_smile:

2 Likes

Good alternative, but I’m still trying to find a solution through welding. Setting part CFrame periodically seems exhaustive to me and looks clunky. Thanks, though!

2 Likes

I’ve seen another very similar post on DevForum about a handcuff system. The writer of this post accomplished a working system with welds and shared the code but discovered it had some problems, such as both dying when one is killed. There’s also the issue with network ownership. Some of these are fixable, but something else that works well is setting the CFrame of the handcuffed player relative to the player who arrested him/her. This is what the writer of that post eventually opted for. You can check it out here:

If you bind the CFrame setting to RunService.Heartbeat, there shouldn’t be any visual problems and should seem smooth. If you insist on using welds, the code that the writer of that post used accomplished it.

1 Like

Good to know, but I’d prefer to fix this problem. The problem has changed, originally I was trying to figure out how to position CFrame appropriate post-welding, but now the problem is my arm faces backwards whatever CFrame I put.

Here’s the recreation of the issue: https://www.roblox.com/library/4890634046/Handcuffs

1 Like