:UnequipTools() Not Working

Hi all,

I’m trying to make an arrest system where you can’t equip any tools while being detained. Here’s the code, very simple:

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character.ChildAdded:Connect(function(item)
			if character:FindFirstChild("ArrestInProgress") then
				if item:IsA("Tool") and item.Name~="Arrest" then
					character.Humanoid:UnequipTools()
				end
			end
		end)
	end)
end)

The problem, however is something I never understood:

I’m guessing this is due to how I instantly change the parent of the tool as soon as I equip it. My question is what does this mean and how can I fix that?

Thanks in advance!

My question is what does this mean and how can I fix that?

Should I use a loop instead?

This usually happens when you delete something the moment a Child object gets added to your Character, preferably a tool in your Instance

You could just use a Heartbeat wait to fix the issue

1 Like

I simply added a wait() and it made a huge difference. Thanks!

You could also use this if you’re picky about using wait():

local RunService = game:GetService("RunService")
game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character.ChildAdded:Connect(function(item)
			if character:FindFirstChild("ArrestInProgress") then
				if item:IsA("Tool") and item.Name~="Arrest" then
                    RunService.Heartbeat:Wait()
					character.Humanoid:UnequipTools()
				end
			end
		end)
	end)
end)

It’d work the same way

1 Like