I’m currently attempting to create a basic handcuff system where the user being cuffed is not able to control their character and is forced to stay in front of someone else. However, I’d like the user who’s being cuffed to have their animations remain the same. I still want it to look like they’re actually walking and moving when they do walk.
This is not working with my current script, does anyone have any ideas on how to fix this?
local module = {}
function module.CuffPlayer(player, targetPlayer)
local playerCharacter = player.Character
local targetCharacter = targetPlayer.Character
if not playerCharacter or not targetCharacter then return end
local playerRoot = playerCharacter:FindFirstChild("HumanoidRootPart")
local targetRoot = targetCharacter:FindFirstChild("HumanoidRootPart")
if not playerRoot or not targetRoot then return end
local offset = CFrame.new(0, 0, -4)
targetRoot.CFrame = playerRoot.CFrame * offset
local humanoid = targetCharacter:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.PlatformStand = true
end
local motor = Instance.new("Motor6D")
motor.Part0 = playerRoot
motor.Part1 = targetRoot
motor.C0 = offset
motor.C1 = CFrame.new()
motor.Parent = playerRoot
local function Uncuff()
if humanoid then
humanoid.PlatformStand = false
end
motor:Destroy()
end
return Uncuff
end
return module
Assuming that you already have the cuffing system work, and only need the animations:
Turn off PlatformStand, as it turns off animations.
Assuming HumanoidA is the police and HumanoidB is the crim, connect Humanoid.StateChanged in HumanoidA such that it replicates the changed state to HumanoidB.
i.e.
local HumanoidA = ...
local HumanoidB = ...
HumanoidA.StateChanged:Connect(function(_, state)
HumanoidB:ChangeState(state)
end)
Note that this code is entirely untested, and may not be the only way to achieve your outcome. There’s no guarantee that it will work but it’s worth a shot!
I updated the script using this to look like this:
local module = {}
function module.CuffPlayer(player, targetPlayer)
local playerCharacter = player.Character
local targetCharacter = targetPlayer.Character
if not playerCharacter or not targetCharacter then return end
local playerRoot = playerCharacter:FindFirstChild("HumanoidRootPart")
local targetRoot = targetCharacter:FindFirstChild("HumanoidRootPart")
if not playerRoot or not targetRoot then return end
local offset = CFrame.new(0, 0, -4)
targetRoot.CFrame = playerRoot.CFrame * offset
local humanoid = targetCharacter:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.PlatformStand = false
end
local HumanoidA = player:FindFirstChild("Humanoid")
local HumanoidB = targetPlayer:FindFirstChild("Humanoid")
HumanoidA.StateChanged:Connect(function(_, state)
HumanoidB:ChangeState(state)
end)
local motor = Instance.new("Motor6D")
motor.Part0 = playerRoot
motor.Part1 = targetRoot
motor.C0 = offset
motor.C1 = CFrame.new()
motor.Parent = playerRoot
local function Uncuff()
if humanoid then
humanoid.PlatformStand = false
end
motor:Destroy()
end
return Uncuff
end
return module
Unfortunately, this doesn’t work and completely broke the script to where the user is initially teleported but then doesn’t stay infront of the user.
What you could try is make a function to check the speed of the character with the handcuffs (the one doing the cuffing), and manually play and stop the walking animation in the character being cuffed.
That won’t work because the character is in PlatformStand which sets the humanoid’s state to Falling. Meaning the default walking animation won’t play. And on top of that, the person being cuffed is not able to move freely. They are welded to the body of the other player.