local RemoteEvent = script.Parent.RemoteEvent
local Using = false
local TargetTorso
local weld
function CheckForChar(Part)
if Part.Parent:IsA('Model') and Part.Parent:FindFirstChildOfClass('Humanoid') then
local Char = Part.Parent
TargetTorso = Char:WaitForChild("HumanoidRootPart")
return Char
end
end
function CheckForTorso(player)
local Char = player.Character
if Char:FindFirstChild('Torso') then
return Char.Torso
else
return Char.UpperTorso
end
end
RemoteEvent.OnServerEvent:Connect(function(player, one, two)
if one == 'Cuff' then
local Target = CheckForChar(two)
local PlayerTorso = CheckForTorso(player)
if Target then
Using = true
RemoteEvent:FireClient(player,'Use')
weld = Instance.new("Weld")
weld.Part0 = PlayerTorso
weld.Part1 = TargetTorso
weld.C0 = CFrame.new(0,0,-3.5)
weld.Parent = PlayerTorso
end
elseif one == 'UnCuff' then
Using = false
weld:Destroy()
script.RunCuff.isOn.Value = false
script.Parent.CuffedPlr.Value = ""
end
end)
script.Parent.Unequipped:Connect(function()
if weld ~= nil then
weld:Destroy()
script.RunCuff.isOn.Value = false
TargetTorso.CanCollide = true
Using = false
script.Parent.CuffedPlr.Value = ""
end
end)
I’m no programmer myself so I am not the best to ask and I don’t know what your end goal is here but maybe I could suggest making it an animation instead?
Will changing the CFrame value of the player slightly help any? What are you talking about “getting stuck”? If the player is dealing with collisions at all, moving the player will help. This might be a bit beyond my experience.
It could have mass and mess with the player to avoid this you would set the massless value in every part of the cuff true(with no mass to the cuff, the weld won’t drag the player)
Your cuff could have collided on, best to turn it off so that the player mesh won’t collide with the cuff model
Make sure to do both of these things. If you have a question about how to do this you can simply ask me and I’ll make a example script to do this
OK. If (from my understanding) the two players are welded together, then maybe the problem lies with physics itself. It looks like you are literally pushing the player. Maybe solve this by making the CFrame value of the victim player an offset of your players current position. Again, I may have no idea what I’m talking about. I’m just throwing something out there.
I actually created a “detain” or handcuff tool for one of the groups I was formerly associated with, or rather was familiar with how it worked. Originally it was a LocalScript HopperBin by Ethancomputermad, all we did was turn it around to be FilteringEnabled.
Essentially, what the tool does is anchor and offset the HumanoidRootPart of the victim about 2.5 studs in front of the handler that’s using the tool. Sometimes, we meet edge cases when people reset or something else unintended happens, though that seems to work alright.
Our model isn’t exactly the best, but you’d definitely want to go for some kind of root part offsetting.
Try setting the cuffed player to his PlatformStand state. When a player is set to this, they can’t run(or move by itself) in any way and makes all of their body non-collidable except the humanoidrootpart.
if Target then
Using = true
RemoteEvent:FireClient(player,'Use')
local CuffedUser = TargetTorso.Parent
local CuffedUserHumanoid = CuffedUser:WaitForChild("Humanoid")
CuffedUserHumanoid.PlatformStand = true
weld = Instance.new("Weld")
weld.Part0 = PlayerTorso
weld.Part1 = TargetTorso
weld.C0 = CFrame.new(0,0,-3.5)
weld.Parent = PlayerTorso
end
of couse you have to make sure you disable PlatformStand when you let go of the player
Use a loop of some kind. You can either use a while condition do loop or something from the RunService. (BindTo)RenderStep(ped) for the client, Stepped for the server.
I don’t think this way is really efficient. You doing a while loop on the server constantly as long as you holding that player, updating his position every frame. When I look at the gif again, it looks like the player is somewhat getting stopped from colliding with something. To stop all collisions with a player you would set PlatformStand on the user to true. This not only makes every part of the user non-collidable but also stops him from moving on his own and you can still play animations while in this State.
I think you’re looking too much into it. Offsetting a HumanoidRootPart is not a complex operation nor is there anything inefficient actually happening here. Inefficient loops are when you run expensive functions very quickly at small intervals.
PlatformStand has no bearing on collisions and animations can be played outside of PlatformStand as well. Player movement is input and can be disabled by sinking input on the client.
Collisions can be nullified using collision groups. PlatformStand basically makes characters “limp” - it was intended for skateboards. It sets the Humanoid to the Freefaling state.