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

How can I equip tools even while the backpack is invisible, is it possible?

Asked by 6 years ago

I want to be able to equip a tool with the toolbar and backpack disabled/unviewable, how would I do so? Is it possible? I tried disabling the backpack and it worked but (of course) I can't equip any tools. Anybody know how I'd pull this off?

1 answer

Log in to vote
0
Answered by 6 years ago

Here's how it works naturally. Tools in the backpack get displayed on the toolbar hud. When you press a key that is bound to the given tool by roblox, the tool is moved from backpack to the player's character. Therefore, we can do something like:

local UIS = game:GetService("UserInputService")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

UIS.InputBegan:Connect(function(key,gameProc)
    if not gameProc then
        if key.KeyCode == Enum.KeyCode.One then
            plr.Backpack.SomeTool.Parent = char
        end
    end
end)

Of course, you could clone the tool into the character and then destroy it from the backpack. The real issues you need to worry about are ordering the tools in the backpack by number and removing previously equipped tools when a new one is equipped!

Ad

Answer this question