Why does this script only work for one person?

  1. I want it to work for more than one person.

  2. The script only lets one player in the game arrest someone.

  3. I have tried to recode the whole thing

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Config = require(workspace.CuffSystem.Config)
local Handler = require(ReplicatedStorage.DataHandlerNOTACONFIG)
local ProxyService = game:GetService("ProximityPromptService")
local Players = game:GetService("Players")
local RemoteEvent = ReplicatedStorage.ExploitProtectionRemoteEvents.RemoteEvent
local Remote2 = ReplicatedStorage.ExploitProtectionRemoteEvents.CuffedPlayer
local ReleaseRemote = ReplicatedStorage.ExploitProtectionRemoteEvents.ReleasePlayer
local DetainRemote = ReplicatedStorage.ExploitProtectionRemoteEvents.DetainPlayer
local ResetButtonRemote = ReplicatedStorage.ExploitProtectionRemoteEvents.DisableResetButton
local InUse = false

function PlayerCuffed(Player, Target)
	local IsPlayer = Players:GetPlayerFromCharacter(Target.Parent) or Players:GetPlayerFromCharacter(Target.Parent.Parent)
	if IsPlayer == nil then
		print(IsPlayer)
		return
	end
	if Handler.registeredPlayers[Player.UserId] >= Config.Arrest and Handler.registeredPlayers[IsPlayer.UserId] < Config.Immune then
	--	if not Players:FindFirstChild(Target.Parent.Name) then
	--		return
	--	end
		local CheckDistance = (Player.Character.HumanoidRootPart.Position - Target.Position).Magnitude
		if CheckDistance <= 15 then
			local Char = IsPlayer.Character
			local Humanoid = Char:FindFirstChild("Humanoid")
			local WeldCheck = Char.HumanoidRootPart:FindFirstChild("DetainWeld")
			if Humanoid  and WeldCheck == nil then
				if Handler.CuffedPlrs[Player] == nil then
					Handler.CuffedPlrs[Player] = IsPlayer
				end
				Humanoid.PlatformStand = true
				local Anim = workspace.CuffSystem:FindFirstChild("ArrestPlayer")
				if Anim then
					local AnimationTrack = Humanoid:LoadAnimation(Anim)
					AnimationTrack:Play()
				else
					warn('Warning: You have removed the ArrestPlayer animation from workspace/CuffSystem therefore we could not play the cuffed animation.')
				end
				task.wait(0.1)
				for i, v in pairs(Char:GetChildren()) do
					if v:IsA("BasePart") then
						v.Massless = true
						v.CanCollide = false
					end
				end
				local Weld = Instance.new("Weld")
				Weld.Name = "DetainWeld"
				Weld.Parent = Char.HumanoidRootPart
				Weld.Part0 = Player.Character.HumanoidRootPart
				Weld.Part1 = Char.HumanoidRootPart
				Weld.C1 = CFrame.new(0,0,3.5)
				local Suspect = Instance.new("StringValue")
				Suspect.Parent = Player.PlayerGui.CuffGUI
				Suspect.Name = "DetainedSuspect"
				Suspect.Value = IsPlayer.Name
				if IsPlayer:FindFirstChild("IsDetained") == nil then
					local IsDetained = Instance.new("ObjectValue")
					IsDetained.Parent = IsPlayer
					IsDetained.Name = "IsDetained"
					IsDetained.Value = Player
				end
				Char.Humanoid.WalkSpeed = 0
				Remote2:FireClient(Player,IsPlayer)
				ResetButtonRemote:FireClient(IsPlayer,"Disable")
				for i, Tool in pairs(IsPlayer.Backpack:GetChildren()) do
					Tool.Parent = IsPlayer.ToolsNotInUse
				end
				for i, Tool in pairs(IsPlayer.Character:GetChildren()) do
					if Tool:IsA("Tool") then
						Tool.Parent = IsPlayer.ToolsNotInUse
					end
				end
			end
		end
	else print(Handler.registeredPlayers[Player.UserId]) return
	end
end

RemoteEvent.OnServerEvent:Connect(PlayerCuffed)