Alr so I have done this, but now something with my collision service went wrong somehow. My whole code is:
-- Arrest System
-- Services
local PlayerService = game:GetService('Players')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local TeamService = game:GetService('Teams')
local PhysicService = game:GetService('PhysicsService') --Error here
-- Refrences
local Remotes = ReplicatedStorage.Remotes
local CuffRemote = Remotes.CuffEvent
local PlayerGroup = PhysicService:CreateCollisionGroup('PlayerGroup')
local PartGroup = PhysicService:CreateCollisionGroup('PartGroup')
PhysicService:CollisionGroupSetCollidable('PartGroup', 'PlayerGroup', false)
-- functions
local function OnCuff(Officer, Victim)
-- Make sure they 'exist' and haven't left the game yet.
if Officer and Victim then
-- Make sure neither of them are dead.
if Officer.Character.Humanoid.Health > 0 and Victim.Character.Humanoid.Health > 0 then
-- Make sure that the player hasn't been cuffed by another officer
if Victim:FindFirstChild('Cuffed') then
return warn('Player cuffed by another officer')
end
if (Victim.Character.Head.Position - Officer.Character.Head.Position).Magnitude > 15 then
return warn('Too far away!')
end
-- Prevent any other officers cuffing the victim
local CuffedValue = Instance.new('IntValue')
CuffedValue.Name = 'Cuffed'
CuffedValue.Value = 1
CuffedValue.Parent = Victim
-- Play cuffed animation
local CurrentAnimations = Victim.Character.Humanoid:GetPlayingAnimationTracks()
-- stop any current animations (such as walking)
for i, track in pairs (CurrentAnimations) do
track:Stop()
end
Victim.Character.Humanoid.WalkSpeed = 0
Victim.Character.Humanoid.JumpPower = 0
Victim.Character.Humanoid.PlatformStand = true
Victim.Backpack.Handcuffs.Parent = game.ServerStorage
Victim.Backpack.ArrestCuffs.Parent = game.ServerStorage
local CuffAnimation = Instance.new('Animation')
CuffAnimation.AnimationId = 'rbxassetid://8722758589'
CuffAnimation.Parent = Victim.Character
local OfficerAnimation = Instance.new('Animation')
OfficerAnimation.AnimationId = 'rbxassetid://8722767340'
OfficerAnimation.Parent = Officer.Character
local LoadedOfficer = Officer.Character.Humanoid:LoadAnimation(OfficerAnimation)
LoadedOfficer:Play()
local LoadedCuff = Victim.Character.Humanoid:LoadAnimation(CuffAnimation)
LoadedCuff:Play()
-- Weld the criminal to the Officer's hand so they can't move
for _, Part in ipairs(Victim.Character:GetDescendants()) do
if Part:IsA('BasePart') then
Part.Massless = true
end
end
if Officer.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Weld = Instance.new('WeldConstraint')
Weld.Name = 'CriminalWeld'
Weld.Part0 = Officer.Character.RightHand
Weld.Part1 = Victim.Character.HumanoidRootPart
Weld.Parent = Officer.Character.RightHand
end
if Officer.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Weld = Instance.new('WeldConstraint')
Weld.Name = 'CriminalWeld'
Weld.Part0 = Officer.Character.RightArm
Weld.Part1 = Victim.Character.HumanoidRootPart
Weld.Parent = Officer.Character.RightArm
end
Victim.Character.HumanoidRootPart.CFrame = Officer.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,.6,-2.5)
Remotes.ReleaseEvent.OnServerEvent:Connect(function()
Officer.Character.RightHand:FindFirstChild("CriminalWeld"):Destroy()
Victim.Character.Humanoid.PlatformStand = false
Victim.Character.Humanoid.WalkSpeed = 16
Victim.Character.Humanoid.JumpPower = 50
LoadedCuff:Stop()
Victim:FindFirstChild('Cuffed'):Destroy()
game.ServerStorage.ArrestCuffs.Parent = Victim.Backpack
game.ServerStorage.Handcuffs.Parent = Victim.Backpack
end)
end
end
end
CuffRemote.OnServerEvent:Connect(OnCuff)```