How to make a tool equip another key

An idea came to me for my shooting game and it is also for mobiles so since Roblox only allows 3 tools visible to the players so I plan to make a tool simply in a different place for the button on the phone or in key “B” in the case of pc but what I don’t know is how to refer to tool.Equiped I mean to make it equip by pressing a button or key.
(I know how to use userinputservice, I know how to activate when clicking a button)
I don’t want a guy to come and say: “Do you want me to give you spoonful by spoonful” NO
I just want to know how to refer to the equipped tool (that with the button or by pressing a key the tool equips the rest I’ll take care of putting the tool in the hidden inventory I know I’ll take care of it thanks in advance

You worded this kind of weirdly, so I’ll go about it how I think you meant this. To get the equipped tool of the player, you would simply do

local tool = character:FindFirstChildOfClass("Tool")

To equip a tool using a custom keybind, it would be

local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key, typing)
    if not typing and plr.Character then
        if key.KeyCode == Enum.KeyCode.B then
            local tool = --whataver

Also, you don’t need to put the tool in a hidden inventory to stop the player from equipping them using 1, 2, or 3, you can simply do:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

from the client.


Thank you very much, I’ll see if it works. Actually, I didn’t know that this instance “equip tools” existed.

hey and I know you already helped me with that but you don’t know by chance how to know if a player is on a phone or tablet and make a button visible?

To check if user is on a phone or tablet, I believe it would be this:

local UIS = game:GetService("UserInputService")

if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.GamepadEnabled then
    --user is on mobile

Sorry for the late reply, was doing other things and hadn’t came back to check.

1 Like

hey I know this topic is over but if you want help me with this topic:

if you have doubts ASK

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.