- pcall(function()
- repeat wait() until game:IsLoaded()
- local plr = game.Players.LocalPlayer
- local function ArrestPlayer(target)
- local count = 0
- while target.Character.Humanoid.WalkSpeed > 0 and target.Character.Humanoid.Health > 0.1 and target:FindFirstChild("Is_Wanted") and count < 50 do
- count = count + 1
- wait(0.1)
- plr.Character:SetPrimaryPartCFrame(target.Character.PrimaryPart.CFrame)
- local args = {
- [1] = "Handcuff",
- [2] = target
- }
- game:GetService("ReplicatedStorage").FE.Handcuffs:InvokeServer(unpack(args))
- end
- wait()
- local args = {
- [1] = "Arrest",
- [2] = target
- }
- game:GetService("ReplicatedStorage").FE.Handcuffs:InvokeServer(unpack(args))
- end
- local function GetWantedPlayers()
- local wanted = {}
- for _, a in pairs(game.Players:GetPlayers()) do
- if a:FindFirstChild("Is_Wanted") then
- table.insert(wanted, a)
- end
- end
- return wanted
- end
- if #GetWantedPlayers() > 0 then
- if plr.Team.Name ~= "Police" then
- local args = {
- [1] = BrickColor.new(102),
- [2] = tostring(math.random(1000, 9999))
- }
- game:GetService("ReplicatedStorage").FE.TeamChange:FireServer(unpack(args))
- wait(6)
- end
- if plr.Team.Name == "Police" then
- for i, v in pairs(GetWantedPlayers()) do
- if v.Character.PrimaryPart then
- ArrestPlayer(v)
- end
- end
- end
- end
- print("finished")
- end)