We use cookies on this site to enhance your user experience

Unequip Tool Keybind

Unequip Tool Keybind

Sep 10 2018, 1:44 AM PST

The following sample will bind the U key to unequip any Tool|Tools the Player currently has equipped.

To use this sample, place it inside a LocalScript within StarterPlayerScripts|StarterPlayer.StarterPlayerScripts.

local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")

local localPlayer = Players.LocalPlayer

ContextActionService:BindAction("unequipTools", 
	function(_, userInputState)
		if userInputState == Enum.UserInputState.Begin then 
			if localPlayer.Character then 
				local humanoid = localPlayer.Character:FindFirstChildOfClass("Humanoid")
				if humanoid then 
					humanoid:UnequipTools()
				end
			end
		end
	end,
	false,
	Enum.KeyCode.U
)