|
| 09 Oct 2017 01:55 PM |
| I want to be able to press Q to equip a sword in my backpack, but I don't want the player to be able to press 1-9 to equip it. How do I do this? |
|
|
| Report Abuse |
|
|
| |
|
|
| 09 Oct 2017 02:01 PM |
| Custom backpack? This would be a local player script correct? |
|
|
| Report Abuse |
|
|
| |
|
Degreds
|
  |
| Joined: 30 Nov 2013 |
| Total Posts: 367 |
|
|
| 09 Oct 2017 02:33 PM |
You do need a custom backpack, but you're going to need to do the GUI yourself. Try putting the tool in a folder in StarterPack. This will make the tool un-equippable with 1-9. Also, this may get long.
Here's a simple script you can put inside the tool to toggle the tool with the Q key:
player = script.Parent.Parent.Parent -- haven't tested this, you might have to fiddle with it repeat wait() until player.Character char = player.Character
tool = script.Parent equipped = false customBackpack = tool.Parent -- tool.Parent should be the folder I mentioned previously.
-- The tool should also be a regular model instead of a tool. This is to prevent players pressing 1-9 to equip it. -- Next, you have to make it stick to the character's hand. You can try looking up a tutorial online for it 'cuz I wanted to keep this simple.
-- Here's the function to toggle the tool. Take note that this will NOT be welded to the character's hand the way I have it now.
game:GetService("UserInputService").InputBegan:connect(function(key) -- UserInputService handles all keyboard inputs. if key.KeyCode == Enum.KeyCode.Q then -- The key variable is the key pressed. This line tests if they keycode of it is Q. if equipped == false then tool.Parent = char else tool.Parent = customBackpack end end end) |
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 09 Oct 2017 02:38 PM |
local plr = game.Players.LocalPlayer local yourTool = ??? game:GetService("UserInputService").InputBegan:Connect(function(key,gpe) if key.KeyCode == Enum.KeyCode.Q and not gpe then if not plr.Character then return end plr.Character.Humanoid:EquipTool(yourTool) end end) |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2017 08:33 PM |
| Thank you so much Degreds. I'll get back to you tomorrow when I can try this and let you know how it goes (: |
|
|
| Report Abuse |
|
|