Can't unequip tool through script

Hello! So Im want make it so player can’t equip tools. However when im doing it I recieve this message:

Something unexpectedly tried to set the parent of Cuffs to Backpack while trying to set the parent of Cuffs. Current parent is Player2.

Here the code im using:

Victim.ChildAdded:Connect(function(child)
	if child:IsA("Tool") then
		Humanoid:UnequipTools()
	end
end)

Any help is appreciated!

1 Like

What is actual Humanoid and Victim variable?

Victim is a character and Humanoid is a humanoid instance (its parent is Victim)

Try this:

Victim.ChildAdded:Connect(function(child)
	if child:IsA("Tool") then
		local Player = game.Players:GetPlayerFromCharacter(Victim)
        child.Parent = Player.Backpack
        task.wait()
	end
end)

Doesn’t work. It’s probably must be done on client side.

alright your script should’ve worked if you have added a delay

put this code inside a normal script inside SSC

local DELAY = 0.05 -- play around with the delay, it  must have a delay

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.ChildAdded:Connect(function(instance)
			if instance:IsA("Tool") then
				wait(DELAY)
				char:WaitForChild("Humanoid"):UnequipTools()
			end
		end)
	end)
end)
2 Likes

char:WaitForChild(“Humanoid”):UnequipTools()

This method works flawlessly as far as I know.

1 Like

You should check this out and highlight it as the best answer.