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?
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)