How can I make an item that cannot be unequipped

How can I make an item that cannot be unequipped and does not show up in the gui?

I’m trying to make a First Person horror-like game and I don’t know how to do so. I also haven’t seen any posts on the forums regarding the topic. (or at least have not come across one)

What should I do?

5 Likes

Firstly, you’re going to need to hide the CoreGui - so they can’t unequip it

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

More info: StarterGui | Documentation - Roblox Creator Hub

Secondly, you’re going to need to equip the tool (You’re going to need the player’s character’s humanoid for this)

Humanoid:EquipTool(plr.Backpack:FindFirstChild("ToolName"))

More info: Humanoid | Documentation - Roblox Creator Hub

If you want to keep the CoreGui I suggest doing:

Tool.Unequipped:Connect(function()
wait()
plr.Backpack:FindFirstChild("ToolName")
end)

Hope I helped.

8 Likes

Just to clarify, disabling the Backpack CoreGui also disables the keyboard controls for equipping and unequipping tools (i.e. pressing 1 to equip/unequip tool no. 1).

2 Likes

Exactly what I was going for. Thanks for the clarification.

Oh, I’ve done this many times. The best way to do this is not to use tools at all.

Make your tools into either accessories or models and weld them to character hands. You can then control the tool in whatever way you want after that - custom tool class, implicitly available code that handles scripts, all up to you.

You don’t need to disable the backpack CoreGui with this solution, though it’d be helpful. This solution also gets rid of the ability to unequip and backspace. One issue you may run into is transparency which you can fix by resetting the LocaTransparencyModifier set by code.

local RunService = game:GetService("RunService")

RunService:BindToRenderStep("ToolVisibility", Enum.RenderPriority.Character.Value + 5, function()
    local Tool = Character.Tool
    for _, descendant in pairs(Tool:GetDescendants()) do
        if descendant:IsA("BasePart") then
            descendant.LocalTransparencyModifier = 0
        end
    end
end)

Above may need tweaking with the priority value.

5 Likes