Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i force a tool to become unequipped?

Asked by 3 years ago

whats the best way to force a player to unequip a tool?

3 answers

Log in to vote
0
Answered by 3 years ago

You can use Humanoid:UnequipTools() or just manually parent the tool to the player's backpack.

Ad
Log in to vote
0
Answered by 3 years ago
player.Character.Humanoid:UnequipTools()

Next time, do research on your question before asking please.

Log in to vote
0
Answered by 3 years ago

Ok so this script Unequips the tool when activated by setting the parent to back pack when activated, the backpack is the folder inside the player where tools are kept when they are not equipped, when a tool is equipped the parent changes to the player's character model, so to unequip it you put it back in the backpack.

script.Parent.Activated:Connect(function()
local player=game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local tool=script.Parent
tool.Parent=player.Backpack
end)

Now I tried to do this with equip event but I got a warning saying "something unexpectedly tried to set the parent of tool to backpack while setting the Parent of tool, the current parent is yumaking"(fyi yumaking is my username and it should be shown when I post this answer). I assume this is becuz the tool was equipped and when a tool is equipped its parent is set to the character model so by trying to set it to the backpack when equipped, I was setting the parent to the character model and the backpack at the same time and then the script was just kinda like "what?", and kept the parent to the player's character model. Anyways that is how I would do it.

Answer this question