How do I make a arrest system?

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve? I want a arrest system for police team.

  2. What is the issue? The Issue is that it doesn’t arrest the criminal when a police is looking at the criminal.

  3. Changing the code a couple of times still doesn’t arrest player. There’s not a there’s no solution on the devforum.

So I already got the arrest gui to show when the police gets near the criminal. Just I need the arresting part to work.

1 Like

Can you give us some context, maybe some code samples? It is very hard for us to understand the problem and help if we don’t understand what is going wrong.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local lastPlayer
local UIEnabled
local length = 20 – distance to scan
local debounce = false

game[“Run Service”].RenderStepped:Connect(function()
local unitRay = camera:ScreenPointToRay(mouse.X, mouse.Y)
local ray = Ray.new(unitRay.Origin, unitRay.Direction * length)
local target = workspace:FindPartOnRay(ray, player.Character)
if target and target.Parent and target.Parent:FindFirstChild(“Humanoid”) then
local playerTarget = game.Players:GetPlayerFromCharacter(target.Parent)
if target then
local lookingat = target.Parent
game.ReplicatedStorage.ArrectPlayer:FireServer(player,lookingat)
end
end
end)

Code one to detect player but how do I make to detect a criminal team?

1 Like

local debounce = true

game.ReplicatedStorage.ArrectPlayer.OnServerEvent:Connect(function(player,lookingat)
print(tostring(player,lookingat))
local player = game.Players[tostring(lookingat)] – Police is looking at
player.datafolder.Arrected.Value = true – Target to set the arrest value
end)

Couldn’t you just use mouse.Target then check if it’s a player?

1 Like

You mean change the local looking at = mouse.Target?

Does your arrest system use a cuff tool to arrest players, like jailbreak’s?

An arrest system like Jailbreaks?

I mean I got the same Gui but my code is not the same and is missing some check to only run code when you hold E.

Do you mean I can check the player but doing if mouse.Target == player.Character then