Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My constraints are not working how I want them to. Anyone have any ideas?

Asked by 7 years ago

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 
03Player = game.Players.LocalPlayer
04mouse = Player:GetMouse()
05debounce = false
06 
07anim = game.ReplicatedStorage.Caught
08 
09script.Parent.Equipped:Connect(function()
10    mouse.Button1Down: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")
View all 52 lines...
0
That can get pretty complex it would seem. I'd just write it from scratch and have the person who's handcuffed move when the captor moves (given that they're at the distance limit) Pejorem 164 — 7y
0
I would prefer the captive to also be able to move around when the captor isn't ThePhantomG 30 — 7y
0
In my example they would be able to Pejorem 164 — 7y
0
Well, thats kinda realistic to have the criminal be able to move handcuffs. hiimgoodpack 2009 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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
02local con
03 
04--Line 10:
05con = mouse.Button1Down:Connect(function()
06 
07--At end of LocalScript:
08script.Parent.Unequipped:Connect(function()
09    if con then
10        con:Disconnect()
11        con = nil
12    end
13end)

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:

01local isCaught = false
02local ropeConstraint, caught, jailed
03function CaughtDone()
04    if isCaught then
05        ropeConstraint:Destroy()
06            caught:Stop()
07            jailed.Humanoid.Walkspeed = 15 -- or whatever
08    end
09    isCaught = false
10end
11 
12--At the beginning of the RemoteEvent:
13    CaughtDone() -- clean up any previous handcuffing
14 
15--Right after "caught:Play()":
View all 22 lines...
0
Where do I put the local "isCaught" to the "isCaught = false" bit? ThePhantomG 30 — 7y
0
In the 2nd script, lines 1-10 are to go at the beginning of your server-script. chess123mate 5873 — 7y
Ad

Answer this question