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

"Handcuff" Tool - How to move the player?

Asked by
LeHelary 142
5 years ago

So I am trying to make a script for a handcuff tool, I don't know much about CFrames but I managed to do this:

[Remote Event]

local offset = CFrame.new(0,0,-2.2)
local char1 = selectedPlr.Character --(The character of the "cuffed" player)
local char2 = plr.Character -- (The character of the player with cuffs)
char1.HumanoidRootPart.CFrame = char2.HumanoidRootPart.CFrame:ToWorldSpace(offset)

This does what I want, and places the "cuffed" player in front of the one with the tool. Image

Now the problem is.. how do I make the cuffed player move as if it was welded to the other?

WeldConstraint didn't work as expected so what should I use?

1 answer

Log in to vote
1
Answered by
KDarren12 705 Donator Moderation Voter
5 years ago
Edited 5 years ago

Use a loop and a variable " cuffed". You'll have to figure out how to enable and disable the variable.

local offset = CFrame.new(0,0,-2.2)
local char1 = selectedPlr.Character --(The character of the "cuffed" player)
local char2 = plr.Character -- (The character of the player with cuffs)
char1:GetMouse(
cuffed = false
game:GetService("RunService").Stepped:Connect(function()
    if cuffed == true then
        char1.HumanoidRootPart.CFrame =                     char2.HumanoidRootPart.CFrame:ToWorldSpace(offset)
    end
end

(Edit to make the player non collidable:)

for i,v in pairs(char1:GetDescendants()) do
    if v:IsA("Part") then
        v.CanCollide = false
    end
end
0
Maybe you could make this a localscript and make a GetMouse from the plr? KDarren12 705 — 5y
0
The script I published was a part of the function that fires with the remote event, the remote event is fired by a local script inside of the tool. This function will be fired for multiple players, so should I use a table instead of the "cuffed" variable, and check if the player is in it? LeHelary 142 — 5y
0
Yeah, I guess that would make more sense. I just thought in the moment a variable would be easier KDarren12 705 — 5y
0
Thank you, it works, the only problem is that sometimes this happens: https://gyazo.com/f9478a3dc9fa246fd59c0d5e00426007 LeHelary 142 — 5y
View all comments (13 more)
0
If you don't know how to fix this I will still accept your answer, however this is kind of annoying LeHelary 142 — 5y
0
Add this to the script to make the player non - collidable: KDarren12 705 — 5y
0
for i,v in pairs(char1:GetDescendants()) do if v:IsA("Part") then v.CanCollide = false end end KDarren12 705 — 5y
0
If you don't understand, this basically goes through everything in the character and makes all parts collidable false. KDarren12 705 — 5y
0
I could also make it formatted and edit my answer KDarren12 705 — 5y
0
I tried this but the character's CanCollide doesn't change! I don't know why, there are no errors. If I try to manually change the CanCollide value of the torso or head server-side this happens https://gyazo.com/2ebaa82793fe2aa0fa7b5152585be96e LeHelary 142 — 5y
0
do you have anything making it collidable...? KDarren12 705 — 5y
0
No, the detain script is literally the only script in the game LeHelary 142 — 5y
0
not sure then. Maybe in the model there is another script?? KDarren12 705 — 5y
0
I really don't know, there's nothing enabling it. I'm gonna try to find a solution, this might be a problem with my game, thank you for your help! LeHelary 142 — 5y
0
Any time! :) KDarren12 705 — 5y
0
I found this article https://developer.roblox.com/en-us/articles/Player-Player-Collisions . Apparently to make a players not collide with other players you need to create a collision group, but that's for all players, and I have no idea how to make only 1 player not able to collide with others. I will probably post a new question for this tomorrow LeHelary 142 — 5y
0
oh ok KDarren12 705 — 5y
Ad

Answer this question