Let's say Player 1 is holding a tool and Player 2 touches the tool. How do I remove the tool from the Player 1's inventory and move it into Player 2's inventory and have them automatically hold it?
COMMUNITY QUESTION
How do I make a Tool stolen by the player who touches it?
1 answer
Server script in the tool
local Players = game:GetService("Players")
local Tool = script.Parent
for Index, Descendant in pairs(Tool:GetDescendants()) do
if Descendant:IsA("BasePart") then
Descendant.Touched:Connect(function(HitPart)
local Character = HitPart.Parent
local Player = Players:GetPlayerFromCharacter(Character)
if Player then
local Backpack = Player:WaitForChild("Backpack")
local Humanoid = Character:WaitForChild("Humanoid")
Tool.Parent = Backpack
Humanoid:UnequipTools()
Humanoid:EquipTool(Tool)
end
end)
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It doesn't work, it only clones the tools and it doesn't equip.
do you have any errors in the output panel