So basically im a builder and im making a prison game, basically i need handcuffs but most of them don’t really have a range and can basically handcuff anyone from any distance and ofcourse that is an issue.
Here are the scripts, credits to Matthew_Plays55 for this cause these are his handcuffs and not mine.
Script :
local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")
local TargetTorso = nil
local Using = false
function CheckForTargetTorso(part)
if part.Parent:IsA'Model' and part.Parent:FindFirstChildOfClass'Humanoid' then
local char = part.Parent
local torso
if char:FindFirstChild'Torso' then
torso = char.Torso
elseif char:FindFirstChild'UpperTorso' then
torso = char.UpperTorso
end
return char, torso
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, state, part)
if state == 'Cuff' then
local target = nil
local playerTorso = nil
target, TargetTorso = CheckForTargetTorso(part)
playerTorso = CheckForTorso(player)
if target then
Using = true
RemoteEvent:FireClient(player, 'Use')
spawn(function()
if Using then
TargetTorso.Anchored = true
end
while Using and wait() do
TargetTorso.CFrame = playerTorso.CFrame * CFrame.new( 0, 0, -5 )
end
end)
end
elseif state == 'UnCuff'then
Using = false
TargetTorso.Anchored = false
wait()
end
end)
local script :
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent
local Using = false
local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")
Tool.Activated:Connect(function()
if not Using then
if Mouse.Target then
RemoteEvent:FireServer('Cuff', Mouse.Target)
end
else
Using = false
RemoteEvent:FireServer('UnCuff')
end
end)
RemoteEvent.OnClientEvent:Connect(function( state )
if state == 'Use' then
Using = true
end
end)
If anyone knows how to add a specific range to these handcuffs, please reply, im not a scripter by any chance since im mostly into building and modelling.