Help with Handcuff tool

So I am trying to make it so that when the player is touched by the handcuff it will play an animation. The script is a server script inside of StarterCharacterScripts.
Here is my code:

game.Players.PlayerAdded:Connect(function(player)
    player.Backpack.Handcuff.Handle.Touched:Connect(function(hit)
	    if hit.Parent:FindFirstChild("Humanoid") then
		    local animation = hit.Parent.Character.Animator:LoadAnimation(script.Animation)
		    animation:Play()
	    end	
    end)
end)

you want the animation to play when you touched a part/handcuffs like the jailbreak arrest system?

Yes. But it isn’t working and I don’t know why.

You forgot the “d” in Humanoid
plus i dont recommend using .Character as it is a property of Player not a Model so change that line to

   		    local animation = hit.Parent.Humanoid:LoadAnimation(script.Animation)

And i believe that will fix it

oops your right but it still didn’t work.
No noticeable errors.

if hit.Parent:WaitForChild("Humanoid") then

That’s a bad practise - :WaitForChild() yields and waits for Humanoid. Instead, replace with :FindFirstChild().

Besides, you can simply define the Humanoid as

local hum = hit.Parent:FindFirstChild("Humanoid")
if not hum then return
--LoadAnimation() code here

It’s not advised to use Humanoid:LoadAnimation(). It’s deprecated, hence it won’t work in the future. Instead, utilise Animator:LoadAnimation().

local animator = humanoid:FindFirstChildOfClass("Animator")
	if animator then
		local animationTrack = animator:LoadAnimation(animation)
		animationTrack:Play()
	return animationTrack
end

Remove PlayerAdded function - it’s not needed, and only replicates the function (allowing it to occur more than once depending upon how many players joined).

As i stated in an edit of my reply i dont recommend using .Character as it is a property of Player not a Model so change that line to

   		    local animation = hit.Parent.Humanoid:LoadAnimation(script.Animation)

And i believe that will fix it

Still didn’t work anything else?

I see still my point on not using .Character still stands as it is a property of a Player instance

I am not calling “Humanoid” as the child of a Model but as the child of the player.

game.Players.PlayerAdded:Connect(function(player)

“player” is the actual player, and “Character” is the player that shows up in the workspace and the one you see when playing a game.

hit is a PART instance. So when you call its parent you are getting the players CHARACTER model already

“hit” is getting whatever part of the player hit the part as in the arm or the torso.

I would also recommend adding lines that verify the player that touched the handcuffs is the player using the handcuffs

which is located in the player’s character model in workspace

local part = --direct pathway for your part that listens to .Touched
part.Touched:Connect(function(h)
	local hum = h.Parent:FindFirstChild("Humanoid")
	--checking for "Humanoid" and "Animator"
	if not hum then return 
	elseif not hum:FindFirstChildOfClass("Animator") then local inst = Instance.new("Animator"); inst.Parent = hum end
	--playing the animation
	local animator = hum:WaitForChild("Animator")
    local animationTrack = animator:LoadAnimation(script.Animation)
	animationTrack:Play()
end)

How would I call the tool when it is in the players backpack without defining the player?

where is the script located. That will depend how you call upon the player

In StarterCharacterScripts. I said that in the beginning.

Why do you want to call the tool? Elaborate. The composed script “calls” itself when the part has collided with another part, potentially Humanoid.

the you call upon player by doing

local char = game.Players:GetPlayerFromCharacter(script.Parent)

thats assuming the script is in the player character model