-- Services and Variables
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local workspace = game:GetService("Workspace")
local starterGui = game:GetService("StarterGui")
local teams = game:GetService("Teams")
local localPlayer = players.LocalPlayer
local eventsFolder = replicatedStorage:FindFirstChild("Events")
local arrestEvent = eventsFolder and eventsFolder:FindFirstChild("Arrest")
-- GUI Elements
local screenGui = Instance.new("ScreenGui", localPlayer:WaitForChild("PlayerGui"))
local mainFrame = Instance.new("Frame")
local titleBar = Instance.new("TextLabel")
local minimizeButton = Instance.new("TextButton")
local startButton = Instance.new("TextButton")
local stopButton = Instance.new("TextButton") -- New Stop button
-- Styling and Layout
screenGui.Name = "ArrestSequenceGUI"
screenGui.ResetOnSpawn = false
-- Main Frame
mainFrame.Size = UDim2.new(0, 250, 0, 100)
mainFrame.Position = UDim2.new(0.5, -125, 0.5, -50)
mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
mainFrame.BorderSizePixel = 0
mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
mainFrame.Visible = true
mainFrame.Parent = screenGui
mainFrame.Active = true
mainFrame.Draggable = true
-- Title Bar
titleBar.Size = UDim2.new(1, 0, 0, 30)
titleBar.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
titleBar.BorderSizePixel = 0
titleBar.Text = "Arrest Sequence"
titleBar.TextColor3 = Color3.fromRGB(255, 255, 255)
titleBar.Font = Enum.Font.SourceSansBold
titleBar.TextSize = 18
titleBar.Parent = mainFrame
-- Minimize Button
minimizeButton.Size = UDim2.new(0, 25, 0, 25)
minimizeButton.Position = UDim2.new(1, -30, 0, 2)
minimizeButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
minimizeButton.Text = "-"
minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
minimizeButton.Font = Enum.Font.SourceSansBold
minimizeButton.TextSize = 18
minimizeButton.Parent = mainFrame
-- Start Button
startButton.Size = UDim2.new(0.8, 0, 0.5, 0)
startButton.Position = UDim2.new(0.1, 0, 0.4, 0)
startButton.Text = "Start Arrest Sequence"
startButton.BackgroundColor3 = Color3.fromRGB(50, 150, 250)
startButton.TextColor3 = Color3.fromRGB(255, 255, 255)
startButton.Font = Enum.Font.SourceSans
startButton.TextSize = 16
startButton.BorderSizePixel = 0
startButton.Parent = mainFrame
startButton.Visible = true
-- Stop Button
stopButton.Size = UDim2.new(0.8, 0, 0.5, 0)
stopButton.Position = UDim2.new(0.1, 0, 0.4, 0)
stopButton.Text = "Stop Arrest Sequence"
stopButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
stopButton.TextColor3 = Color3.fromRGB(255, 255, 255)
stopButton.Font = Enum.Font.SourceSans
stopButton.TextSize = 16
stopButton.BorderSizePixel = 0
stopButton.Parent = mainFrame
stopButton.Visible = false
-- Notification Function
local function notify(message)
starterGui:SetCore("ChatMakeSystemMessage", {
Text = message;
Color = Color3.new(0, 1, 0);
Font = Enum.Font.SourceSansBold;
TextSize = 18;
})
end
-- Toggle for Minimizing/Maximizing the GUI
local isMinimized = false
minimizeButton.MouseButton1Click:Connect(function()
isMinimized = not isMinimized
startButton.Visible = not isMinimized and not stopButton.Visible
mainFrame.Size = isMinimized and UDim2.new(0, 250, 0, 30) or UDim2.new(0, 250, 0, 100)
end)
-- Gather all Criminals Spawn locations
local spawnLocations = {}
local spawnFolder = workspace:FindFirstChild("Criminals Spawn")
if spawnFolder then
for _, spawnPoint in pairs(spawnFolder:GetDescendants()) do
if spawnPoint:IsA("BasePart") then
table.insert(spawnLocations, spawnPoint.Position)
end
end
end
-- Define the range around the spawn points to skip arrests
local spawnRange = 10
-- Variable to control stopping the sequence
local shouldStop = false
-- Function to equip the cuffs with refreshed character and backpack references
local function equipCuffs()
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local backpack = localPlayer:FindFirstChild("Backpack") or character:WaitForChild("Backpack")
local cuffs = backpack:FindFirstChild("Handcuffs")
if cuffs then
cuffs.Parent = character
notify("Handcuffs equipped.")
return true
else
notify("Handcuffs not found in Backpack.")
return false
end
end
-- Function to de-equip cuffs
local function unequipCuffs()
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local backpack = localPlayer:FindFirstChild("Backpack") or character:WaitForChild("Backpack")
local cuffs = character:FindFirstChild("Handcuffs")
if cuffs then
cuffs.Parent = backpack
notify("Handcuffs de-equipped.")
end
end
-- Function to check if the target is near any spawn point
local function isNearSpawn(targetPosition)
for _, spawnPosition in ipairs(spawnLocations) do
if (targetPosition - spawnPosition).Magnitude <= spawnRange then
return true
end
end
return false
end
-- Function to manipulate target position temporarily and attempt arrest with delay
local function attemptArrestWithDelay(targetPlayer)
if shouldStop then return end -- Stop the sequence if requested
local targetCharacter = targetPlayer.Character
if targetCharacter then
local originalPosition = targetCharacter:GetPivot().Position
if isNearSpawn(originalPosition) then
notify(targetPlayer.Name .. " is too close to the spawn area; skipping arrest.")
return
end
local randomOffset = Vector3.new(math.random(-2, 2), 0, math.random(-2, 2))
targetCharacter:SetPrimaryPartCFrame(localPlayer.Character:GetPivot() * CFrame.new(0, 0, -5) + randomOffset)
local success = arrestEvent:InvokeServer(targetPlayer)
if success == true then
notify("Successfully arrested " .. targetPlayer.Name)
else
notify("Arrest failed: " .. tostring(success))
end
targetCharacter:SetPrimaryPartCFrame(CFrame.new(originalPosition))
task.wait(6)
else
notify("Could not locate character for " .. targetPlayer.Name)
end
end
-- Main Function to Execute Arrest Sequence
local function executeArrestSequence()
if equipCuffs() then
shouldStop = false
stopButton.Visible = true -- Show the Stop button
startButton.Visible = false -- Hide the Start button
for _, player in pairs(players:GetPlayers()) do
if player.Team and player.Team.Name == "Criminals" then
attemptArrestWithDelay(player)
if shouldStop then break end -- Break if stop button is clicked
end
end
unequipCuffs()
notify("Arrest sequence completed. Click the button to restart.")
stopButton.Visible = false -- Hide the Stop button
startButton.Visible = true -- Show the Start button
else
notify("Could not equip handcuffs.")
end
end
-- Check if the player is on the Guards team before allowing the arrest sequence to run
local function checkGuardsTeam()
if localPlayer.Team and localPlayer.Team.Name == "Guards" then
executeArrestSequence()
else
notify("You must be on the Guards team to run the arrest sequence.")
startButton.Visible = true
end
end
-- Button Click Events
startButton.MouseButton1Click:Connect(function()
checkGuardsTeam() -- Ensure the player is on the Guards team before running the arrest sequence
end)
stopButton.MouseButton1Click:Connect(function()
shouldStop = true
stopButton.Visible = false -- Hide the Stop button
startButton.Visible = true -- Show the Start button
notify("Arrest sequence stopped.")
end)
Comments
does it work with velocity?