So Basically, I already know how I can equip a "Tool" using a key bind Here is my Code, For a FlashLight
local player = game.Players.LocalPlayer local character = player.Character game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then print("R was pressed") if player and player.Character then local humanoid = player.Character:FindFirstChildOfClass("Humanoid") if humanoid then local tool = workspace:FindFirstChild("Flashlight") if tool then humanoid:EquipTool(tool) end end end end end)
So This script makes you equip "Tool" when you click R but I don't know where to put the "Humanoid: UnequipTool(tool)" in this part
So Basically This is my general question: How do I make my script when I press "R" it equips the tool but when I press "R" again it unequips the tool
sorry I was confused about this
Okay i Found out that 2 local script is needed about this, one is Equip and one is Unequip
Put those local scripts at the StarterGui
You need 2 Tools, One is in the StarterPack, and the other One is in the Replicated Storage for cloning
For the Equip Local Script
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:connect(function(Key) Key = Key:lower() if Key == 'r' then game.Workspace:FindFirstChild(Player.Name).Humanoid:EquipTool(Player.Backpack."Your Tool") script.Parent.Unequip.Disabled = false script.Disabled = true end end)
For the Unequip Local Script
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:connect(function(Key) Key = Key:lower() if Key == 'r' then game.Workspace:FindFirstChild(Player.Name)."Your Tool":remove() game.ReplicatedStorage."Your Tool":clone() game.ReplicatedStorage."Your Tool":clone().Parent = game.Players.LocalPlayer.Backpack script.Parent.Equip.Disabled = false script.Disabled = true end end)