I am making a handcuff system that doesn't just teleport the criminal, it makes the police hold the criminal i his hands so the police can drag around the criminal. The objective is to weld the criminals torso to the police's right hand. For the police, the animations for both players show, and the criminal is welded to the police perfectly, but for the criminal, they are not welded and can walk around freely and the animation doesn't play. I have this script in a local script in starterplayerscripts. What do I need to change to make it work for both players?
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local HoldAnimID = "rbxassetid://5309354611" -- anim for police
local CuffAnimID = "rbxassetid://5309476655" -- anim for criminal
local handcuffGUI = player.PlayerGui.PoliceGUI.handcuff -- gui for police
local title = handcuffGUI.title -- title in police gui that displays criminal's name (works)
local placeEvent = game.ReplicatedStorage.arrestEvents.place -- these 4 events are for later
local releaseEvent = game.ReplicatedStorage.arrestEvents.release
local arrestEvent = game.ReplicatedStorage.arrestEvents.arrest
local searchEvent = game.ReplicatedStorage.arrestEvents.search
mouse.Button1Down:Connect(function()
print("button down")
if mouse.Target ~= nil then
print("target is: ", mouse.Target)
local target = mouse.Target.Parent:FindFirstChild("Humanoid") -- checks if mouse target is a player
if target ~= nil then
print("human target is: ", target.Parent)
handcuffGUI.Visible = true -- this works
title.Text = "Handcuffed: "..target.Parent.Name
local hand = player.Character.RightHand -- police hand
local torso = target.Parent.LowerTorso -- criminal torso
torso.Parent:GetChildren().CanCollide = false -- criminal cancollide is off
local HoldAnimation = Instance.new("Animation") -- police anim play
HoldAnimation.AnimationId = HoldAnimID
local LoadHoldAnimation = player.Character.Humanoid:LoadAnimation(HoldAnimation)
LoadHoldAnimation:Play()
local CuffAnimation = Instance.new("Animation") -- crim anim play (only shows for cop)
CuffAnimation.AnimationId = CuffAnimID
local LoadCuffAnimation = target:LoadAnimation(CuffAnimation)
LoadCuffAnimation:Play()
torso.CFrame = hand.CFrame * CFrame.new(0,-.7,1) * CFrame.Angles(math.rad(270),0,0) -- weld that only works for cop
local weld = Instance.new("Weld")
weld.Part0 = hand
weld.Part1 = torso
weld.C0 = hand.CFrame:Inverse()
weld.C1 = torso.CFrame:Inverse()
weld.Parent = hand
end
end
end)
