Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make UserInputService stop checking for "e" press?

I'm making a press e to pick up and put down, but I also have a press e to put the item onto, lets say a table. When I'm near this table, it starts checking for "e" press to put it on the table, however, if I were to walk away it would still check for "e". So, is there a way to make UserInputService stop checking for "e"? It pretty much merges with the pick up and down press "e" script such that when I press "e" both scripts activate.

1 answer

I don't know of a method to do this, BUT you can simply have a variable to hold if the player is holding an item or not, and when the e key is pressed, check that variable before doing anything.

EDIT:

local holding_item = false
 --Trigger
	if holding_item ~= true then
		holding_item = true
		-- Is not holding an item
	else
		holding_item = false -- if drops on the spot
		-- is holding an item
	end
end

1 comment

0

Could you give me an example, I'm currently very confused with what I should do.

This discussion is preserved as it was. New answers, comments, and votes are closed.