Prevent player from unequipping / changing weapon

What is the best way to prevent player from unequipping / changing weapon while performing an attack until they finished?

Is using,

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

a good idea to use everytime a player performs an attack, and enabling it again when the attack is finished? Does that also prevent them from unequipping?

It does prevent players from switching and unequipping the item but they can still unequip it with backspace.

Can I prevent them from doing that as well?

Then you can check constantly whether the tool has been reparented (character.ChildRemoved and check whether the returned instance is the tool), and if it was, just equip it again using Humanoid:EquipTool().

The only way i could think of doing it is whenever player unequipps a tool you would force equip it.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')

script.Parent.Unequipped:Connect(function()
	task.wait(0.01)
	Humanoid:EquipTool(script.Parent)
end)
2 Likes

But you will see the player equipping it again very quickly, it’s not smooth

Well, there is an approach that is going to be extremely annoying to say but making a custom Backpack. You can find more creative methods to overcome this individual problem, but if your game will further have to disable more core mechanics with the core Backpack, I would suggest scripting a custom one, as that will save you a lot of headache.

2 Likes