--# Cleanup if _G.Looping then _G.Looping = false end if _G.Active then _G.Active = false end if _G.Signal then _G.Signal:Disconnect() end --# Globals variables _G.Keybind = Enum.KeyCode.F --# Toggle bind. _G.Looping = true --# State of main loop. _G.Active = false --# Whether the user may jail them. _G.Signal = nil --# Holding signal of keybind & state of active. --# Services local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") --# Variables local Player = Players.LocalPlayer local Fe = ReplicatedStorage:FindFirstChild("FE") local UseHandcuffs = Fe and Fe:FindFirstChild("UseHandcuffs") --# Functions local function IsInDistance(Vec1: Vector3, Vec2: Vector3, Dist: number): boolean return (Vec1 - Vec2).Magnitude <= Dist end local function HasToolInToolbar(ToolName: string): boolean local Tool = Player.Character and Player.Character:FindFirstChild(ToolName) return (Tool and Tool:IsA("Tool")) or false end local function GetPositionOfModel(Model: Model?): Vector3? return (Model ~= nil and Model:GetPivot().Position) or nil end local function IsPlayerLocal(Player: Player): boolean return Player == Players.LocalPlayer end local function IsPlayerInTeam(Player: Player, Team: string): boolean return (Player.Team and Player.Team.Name == Team) or false end --# Root loops _G.Signal = UserInputService.InputBegan:Connect(function(input, event) if not event and input.KeyCode == _G.Keybind then _G.Active = not _G.Active end end) while _G.Looping do if _G.Active and HasToolInToolbar("Handcuffs") then --# Check if interation allowed for _, user in Players:GetPlayers() do if (not IsPlayerLocal(user) and IsPlayerInTeam(user, "Civilian")) then if Player.Character and user.Character then local p1 = GetPositionOfModel(Player.Character) local p2 = GetPositionOfModel(user.Character) if not ( _G.Active and HasToolInToolbar("Handcuffs")) then break--# Resolve useless iteration end if HasToolInToolbar("Handcuffs") and IsInDistance(p1, p2, 18) then UseHandcuffs:InvokeServer("Handcuff", user) UseHandcuffs:InvokeServer("Arrest", user) end end end end end task.wait() end