How do i make tools not being able to Unequip, but only being able to switch to other Tools?

So, i want to make it so that once you spawn you will be automatically given the first tool in the Player Backpack, but you can not deselect/unequip the tool and you can only switch to the other tools by pressing one of the number keys on the keyboard.

I only found a script with the player spawning in with one of the tools, but i can’t seem to find a script where you can’t be holstered. Here is the script (you can get it at https://create.roblox.com/marketplace/asset/417063995/Never-Unequip-Tool):

task.wait(1)
local tool = script.Parent
local player = game.Players.LocalPlayer
local hum = player.Character.Humanoid

tool.Equipped:Connect(function()
	game:GetService("RunService").RenderStepped:connect(function()
		if not hum.Parent:FindFirstChild(tool.Name) then
			hum:EquipTool(tool)
		end
	end)
end)

I am asking this because i want this feature to be used in my horror and FPS games.

This is my first devforum post. Also, i apologize if i am asking too much.

Not sure if you can do this. However, you can do something like this so if they unequip the tool, the tool is equipped again.

tool.Unequipped:Connect(function()
	wait()
	Humanoid:EquipTool(tool)
end)

I already found a script like this, though thank you for trying to help me.

1 Like

Ah apologies, didn’t see that you said that.

I’ve read a bit and I think it’s not possible to do this. I would read this post: Unequipping Tools

I don’t think that it is completely impossible, because last time i saw Arsenal using the same equip mechanic.

They have a custom tool system I am pretty sure which is why they can’t unequip.

1 Like

Alright then, thank you for helping me once again.

1 Like

You can use this snippet to disable the Tool CoreGui to disable equipping and unequipping tools:

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

Put that in a local script in StarterCharacterScripts

To be able to switch to other tools I would have a local script using ContextActionService, placed in StarterCharacterScripts

This is pseudo-code and not tested but you might get it to work to your own liking and improve upon it:


--Services
local contextAction = game:GetService("ContextActionService")
local starterGui = game:GetService("StarterGui")
local playerService = game:GetService("Players")

--Disable Tool CoreGui
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

--Player Stuff
local player = playerService.LocalPlayer
local backpack = player.Backpack

--Main Switch Tool
local function switchTool(action, inputState)
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")

--Switch to first
	if action == "switchFirst" and Enum.UserInputState.Begin then
		local tool = backpack:FindFirstChild("") --Insert Tool Name
		if tool then
			humanoid:UnequipTools()
			tool.Parent = character
		end	
	end

--Switch to second
	if action == "switchSecond" and Enum.UserInputState.Begin then
		local tool = backpack:FindFirstChild("") --Insert Tool Name
		if tool then
			humanoid:UnequipTools()
			tool.Parent = character
		end	
	end
end

contextAction:BindAction("switchFirst", switchTool, true, Enum.KeyCode.One)
contextAction:BindAction("switchSecond", switchTool, true, Enum.KeyCode.Two)
1 Like

Thank you a lot, i will test this code and if it works im gonna mark this reply as a solution.

EDIT: It worked, changed the code a bit to work a bit more decent. Thanks

1 Like