Hello! I tried to make something like this without the billboard gui’s but for some reason mine doesn’t weld it like this one. https://gyazo.com/34dcd9f559c35925297ee505f9848418
I want a detain handcuff script. For me, it looks like this:
My script:
--//local script//--
local Cuff = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local Handle = Cuff.Handle
local mouse = plr:GetMouse()
local isEquipped = false
local MyHumanoidRootPart = char:FindFirstChild("HumanoidRootPart")
local MyHumanoid = char:FindFirstChild("Humanoid")
local Range = 200
Cuff.Equipped:Connect(function()
isEquipped = true
end)
Cuff.Unequipped:Connect(function()
isEquipped = false
end)
mouse.Button1Down:Connect(function()
if isEquipped then
local ray = Ray.new(Handle.CFrame.p, (mouse.Hit.p - Handle.CFrame.p).unit * Range)
local part, position = workspace:FindPartOnRay(ray, plr.Character, false, true)
if part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid") then
local TargetHumanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
local TargetHumanoidRootPart = TargetHumanoid.Parent:FindFirstChild("HumanoidRootPart")
game.ReplicatedStorage.Cuff:FireServer(TargetHumanoid, TargetHumanoidRootPart)
end
end
end)
--//server script//--
local RS = game:GetService("ReplicatedStorage")
local CuffEvent = RS:FindFirstChild("Cuff")
CuffEvent.OnServerEvent:Connect(function(plr, TargetHumanoid, TargetHumanoidRootPart)
TargetHumanoidRootPart.CFrame = plr.Character:FindFirstChild("HumanoidRootPart").CFrame + CFrame.new(10, 0, 0)
local weld = Instance.new("Weld")
weld.Part0 = plr.Character:FindFirstChild("HumanoidRootPart")
weld.Part1 = TargetHumanoidRootPart
weld.C0 = plr.Character:FindFirstChild("HumanoidRootPart").CFrame:Inverse()
weld.C1 = TargetHumanoidRootPart
weld.Parent = game.Workspace
end)