script.Parent.Handle.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Team == Criminal hit.Parent:MoveTo(game.Workspace.Part.Position) end end)
The script works if I don't put if hit.Team == Criminal, but it will work if the player is in a team like Police.
How do I make it so it only can arrest Criminals?
In your script, hit refers to the literal brick that touches the handle, for example a left arm or a right leg. Team is a property of the player class, so you will need to edit line 2 like so:
if game.Players:GetPlayerFromCharacter(hit.Parent).Team = game:GetService("Teams"):FindFirstChild("Criminal") then
Of course, I'm assuming Criminal is the name of your team. If any of these functions sound new to you, look them up on the Roblox wiki. Hope this helps
Since you are using the Touched
function, the parameter hit
you defined will be something the handcuffs collide with, not the targeted player. You would have to find the player through the character. You also forgot another end
script.Parent.Handle.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) --gets player from character if player then --checks if the player exists if player.Team == game:GetService("Teams"):FindFirstChild("Criminal") then hit.Parent:MoveTo(game.Workspace.Part.Position) end end end end)