I'm using a RopeConstraint as handcuffs so when you click on a player with the handcuffs, you can jail them and pull them wherever you would like. However it gets glitchy and the jailed person can actually move by pulling the handcuff holder when he's not moving. I've tried attaching the constraints to the HumanoidRootPart, Legs, Arms, Torso and even the tool itself but none of them solve this problem. Its filtering enabled compatible currently. And if anyone knows how to solve the problem with me still being able to use the tool once I've unequipped it for the first time, please let me know.
01 | ** -- Local Script** |
02 |
03 | Player = game.Players.LocalPlayer |
04 | mouse = Player:GetMouse() |
05 | debounce = false |
06 |
07 | anim = game.ReplicatedStorage.Caught |
08 |
09 | script.Parent.Equipped:Connect( function () |
10 | mouse.Button 1 Down:Connect( function () |
11 | if mouse.Target ~ = nil then |
12 | local Hit = mouse.Target |
13 | print ( "hi" ) |
14 | 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 |
15 | print ( "hi" ) |
Create an invisible, anchored, non-collidable Part that is continuously updated to have its Position equal to the torso of the one holding the handcuffs.
The reason you can still use the tool after unequipping is because you never destroy the connection you made to mouse.Button1Down.
01 | --Near top |
02 | local con |
03 |
04 | --Line 10: |
05 | con = mouse.Button 1 Down:Connect( function () |
06 |
07 | --At end of LocalScript: |
08 | script.Parent.Unequipped:Connect( function () |
09 | if con then |
10 | con:Disconnect() |
11 | con = nil |
12 | end |
13 | end ) |
Also, you shouldn't connect to events within other events (server-script, line 46) -- you'll end up making more than one connection over time. Instead, use a boolean variable, like this:
01 | local isCaught = false |
02 | local ropeConstraint, caught, jailed |
03 | function CaughtDone() |
04 | if isCaught then |
05 | ropeConstraint:Destroy() |
06 | caught:Stop() |
07 | jailed.Humanoid.Walkspeed = 15 -- or whatever |
08 | end |
09 | isCaught = false |
10 | end |
11 |
12 | --At the beginning of the RemoteEvent: |
13 | CaughtDone() -- clean up any previous handcuffing |
14 |
15 | --Right after "caught:Play()": |