Custom Backpack equip problem

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to Make my own Backpack type of thing

  2. What is the issue? Include screenshots / videos if possible!
    I’m Using UserInputService to Detect when The player presses a Number but Using

   game:GetService("UserInputService").InputBegan

Makes it so If you hold it, it will unequip and equip rapidly, what I want is if you press the one key one time it will equip, and if you press it another time it will unequip just like the standard Backpack

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried Checking if the Player has the tool but I want if you press one the second time it unequips so it wont do anything if your just holding 1 down
UserInputService.InputBegan:Connect(function(Input)
	if Input.KeyCode == Equip1 then
		if not Character:FindFirstChild("P90") then
			Humanoid:EquipTool(Player.Backpack:FindFirstChild("P90"))
 
		end
	elseif Character:FindFirstChild("P90") then
		Humanoid:UnequipTools()
	end
end)

Sorry if This Post is a Little Confusing

So what you need is to make a debounce, something like this

local debounce = false

UserInputService.InputBegan:Connect(function(Input)
   if debounce == false then
     if Input.KeyCode == Equip1 then
	    if not Character:FindFirstChild("P90") then
		   Humanoid:EquipTool(Player.Backpack:FindFirstChild("P90"))

	    end
    elseif Character:FindFirstChild("P90") then
	    Humanoid:UnequipTools()
    end
    debounce = true
end
end)

then in your

UserInputService.InputEnded

you want to set it back to false!

1 Like

It Doesn’t Work, it just does the same thing.

nvm I fixed it


UserInputService.InputBegan:Connect(function(Input)
	if debounce == false then
		if Input.KeyCode == Equip1 then
			if not Character:FindFirstChild("P90") then
				Humanoid:EquipTool(Player.Backpack:FindFirstChild("P90"))
			else
				Humanoid:UnequipTools()
			end
		end
	end
end)
2 Likes