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

When hiding the backpack the tools don't work?

Asked by 6 years ago
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

i used this to hide/disable the default backpack. I am making my own inventory and when you click the gui for equipping it equips it onto the character. the tools work if the backpack is not hidden.

Would this mean i would have to manipulate the code in the actual tool so it would know when the tool is equipped (true or false boolean) and then if its equipped then whenever i click the screen it would perform whatever the tool does?

Thank you for reading, I want to ask this question to know if there's a more efficient method in doing this.

1 answer

Log in to vote
1
Answered by 6 years ago

You can manually equip a tool like this:

local Player = game.Players.LocalPlayer
local Character = Player.Character

function EquipTool(toolname)
    for _, v in pairs(Player.Backpack:GetChildren()) do 
        if v:IsA('Tool') and (v.Name == toolname) then 
            DequipTool() -- unequip any other tools
            v.Parent = Character
        end
    end
end

function DequipTools()
    for _, v in pairs (Character:GetChildren()) do 
        if v:IsA('Tool') then 
            v.Parent = Player.Backpack
        end
    end
end
0
Thanks but it didnt answer the question i just had to manipulate the code using userinputservice instead of tool.Activated. LordOfWatermelons 27 — 6y
Ad

Answer this question