Hello everyone, I have a shop which opens pressing e, the problem is that the shop opens when you type in chat too, how do I fix this?
if input.KeyCode == Enum.KeyCode.E then
if (camera.CFrame.Position - model.PartUI.Position).Magnitude <= 20 then
for i, v in pairs(ui:GetDescendants()) do
if v.ClassName == "Frame" or v.ClassName == "ScrollingFrame" or v.ClassName == "TextButton" or v.ClassName == "TextLabel" or v.ClassName == "ViewportFrame" then
v.Visible = true
model.PartUI.BillboardGui.Frame.Visible = false
model.PartUI.BillboardGui.Frame.TextLabel.Visible = false
The structure of the code will be greatly appreciated in order to find a solution.
I’m assuming you’re using
UserInputService input events, correct me if I am wrong?
In the input events, the second argument is
gameProcessedEvent which describes if the game has processed that input previously.
This means if you’re typing in a TextBox, for example, it’d be true as the game has processed that input.
You wanna make a check to see if it’s true and if it is you stop the code there.
Here would be a code sample how it could look like:
if gameProcessedEvent then
-- ... rest of the code here
This is how Developer Hub describes
Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input,
gameProcessedEvent would be true . This is also true for input events connected via
I’m pretty sure that using context action service would resolve this issue. I think that you can also use the gameProcessedEvent parameter to stop this from happening.
Game Processed Event just detects if you want the script to run if you are typing in chat.
If you want to fix your script, you should write:
if gameProcessedEvent then return end
if input.KeyCdoe == Enum.KeyCode.E then
-- Put rest of code here