CFrame handcuffs causing player to bounce around

Hello there. I will try not to make this post too long. Recently, I made this post asking how to make an efficient handcuff system. After some discussion and testing, I decided to use a CFrame system in which the cuffed player’s NetworkOwner is the player grabbing him and a local script inside the player grabbing sets the CFrame of the player being cuffed.

That works great, but there is one major problem. When looking at the player being cuffed from a third-person perspective (any player that isn’t the player grabbing), it looks like the player is bouncing around and glitching all over the place. Here is an example:


My question is, is there a way to eliminate this glitch? I really have no idea why it happens or how to eliminate it. I have tried CFraming the player a little higher than the ground in order it clipped with the ground, but that didn’t work. I really do want to keep the NetworkOwnership of the player cuffed to the player grabbing since it prevents laggy movement and looks smooth on the screen of the player that is grabbing, which is a necessity when making these systems. Here is the script:

-- Variables --

local RunService = game:GetService("RunService")

local Players = game:GetService("Players")
local Player = Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local ArrestData = Character:WaitForChild("ArrestData")
local Grabbing = ArrestData:WaitForChild("Grabbing")

local GrabbingCharacter = Grabbing.Value.Character or Grabbing.Value.CharacterAdded:Wait()
local GrabbingHumanoidRootPart = GrabbingCharacter:WaitForChild("HumanoidRootPart")

local CanContinue = true

-- Scripting --

RunService.Heartbeat:connect(function(Beat)
	if CanContinue == true then
		if Grabbing.Value ~= nil then
			GrabbingHumanoidRootPart.CFrame = HumanoidRootPart.CFrame * CFrame.new(0, 0, -2.5)
		else
			CanContinue = false
			script:Destroy()
		end
	end
end)

If you could help me, that would be amazing. Thank you for your time and effort.

2 Likes

Hey!

May we see your script? That way we can actually help you!

Of course, my bad. I will edit soon.

I see your script or something is in the post provided, however some may just want to browse this topic, so the script should also be located here!

1 Like

My bad. I edited the post and included the script in there.

1 Like

To give a smoother effect, you could place the humanoid in the desired location and then weld the players hrp to the other person, which should remove the bounce effect.

2 Likes

What skilled said. Set the character’s position in front of you, then create a weld constraint. When I made a detain script, I put the target humanoid’s(person getting cuffed) PlatformStand property to true. That way, they can’t do anything. edit: Another thing, make sure to set every part inside the character to Massless.

1 Like

You should maybe try this code

RunService.Heartbeat:connect(function(Beat)
	if CanContinue == true then
		if Grabbing.Value ~= nil then
			local LastCF = nil
			if LastCF == nil then
				LastCF = HumanoidRootPart.CFrame
			end
			local R = HumanoidRootPart.CFrame * LastCF:Inverse()
			LastCF = HumanoidRootPart.CFrame
			
			GrabbingHumanoidRootPart.CFrame = (R * HumanoidRootPart.CFrame) * CFrame.new(0, 0, -2.5)
		else
			CanContinue = false
			script:Destroy()
		end
	end
end)

I also tested it and it seems like it works robloxapp-20200513-0433028.wmv (724.1 KB)

1 Like

It’s because they are constantly ‘falling’, causing them to build velocity endlessly. Send their Velocity as well as their CFrame on Heartbeat to Vector3.new(0,0,0) and the problem should go away.

2 Likes

Try to anchor the HumanoidRootPart, from what i see it keeps falling down.

2 Likes

Pretty sure its actually just that, as @Expertsm said, make sure you anchor the rootpart. And if you want to go overkill, disable the player’s controls/movement as a sure fire way to make sure they aren’t moving :man_shrugging:

Also, avoid doing too many updates on the server, if you still want the handcuff look with the player infront of the player. You can handle the movements on the client/movement replication while the server just keeps track of the pos infront of you and updates it towards the other player’s rootpart to move there.

Lessens lag and makes it easy.

2 Likes

Idk if you have already considered this or not, but try setting the network owner of the avatar of that player’s avatar to the person who has a cuff, and use weld constraint to weld his torso.

This is a great way of going about it, you just have to be very careful you give network ownership back or else movement will become extremely laggy for the player being handcuffed after they are let go. Also, I personally recommend using an AlignPosition and AlignOrientation object. I think I made a free model handcuffs using this if anyone wants to try it out.

https://www.roblox.com/library/4367807162/Smooth-Handcuffs

I want to thank everyone for their replies. It really helped me. From my side, I want to apologize for kind of rushing this post. I forgot to add some major detail behind the script which certainly confused some people. Hopefully, this reply will answer those questions. Although I do not believe I need to edit the post since it has been solved, I can edit it if requested to. Let me reply to each reply one by one.

This is indeed a smart way to approach it, but I am using a CFrame system because I want to avoid welds. I’ve used welds before and I personally do not want to go through the struggle of facing the same bugs I faced before. @skillednames @iiFusionzX

That seemed to have solved the problem. I just needed to set the velocity to 0 and it all worked fine. @Zeezy2204

The reason this didn’t work was because of my failure to explain how the script exactly worked. I didn’t try anchoring from the client, but when I anchored from the server, it would just CFrame the character locally and not globally, which meant that I would have to have a different loop outside the client that would loop through and set the CFrame of the character, which would beat the purpose of the local script and take up more resources, which is something I would not want. I did try it with another loop on the server and it did worked, but it takes more resources that it should. Again, the only reason it did not work was because of me not explaining what the script above was. @Expertsm

As I mentioned above, I didn’t explain it right. I do disable the controls, make all the part massless and set their NetworkOwner to the player grabbing, and I make the player cuffed PlatformStand. Also, the script above is a script cloned in the player grabbing so that everything is handled by the client and the server does not get stressed, that is exactly why the player grabbing doesn’t experience any lag at all. My fault for not explaining correctly. @3rdhoan123 @iiFusionzX @Yuuwa0519

I actually have many checks in place so that it gives the NetworkOwnership back to the player being cuffed, so that solves that problem. Also, the model isn’t free, but that is alright, thank you for considering it. @Zeezy2204

In conclusion, this post was somewhat rushed and incomplete, and that was completely my fault. Either way, I want to thank everyone who replied and tried to help me with this. I really appreciate you all helping me. I might edit the post, but I might not since the solution is found. Again, thank you everyone for the help.

2 Likes