I migrated the chat, and when I type 1 in the chat, the tool called 1 in the backpack is equipped.
How can I get rid of this?
I want to prevent tools from being equipped while chatting.
I think contextactionservice would work.
How do I add contextactionservice?
ContextActionService:BindAction("name", yourfunciton, createTouchButton, keycode)
make sure it’s done on the client.
It appears you have a custom inventory/hot-bar system. Given the context in the video, it most likely uses UserInputService to respond to keyboard inputs. It seems it’s lacking an elementary guard clause for stopping the callback if Roblox is responding to the input itself. In this scenario, Roblox is processing the keyboard input so it may update the TextBox.Text
field with the user’s inputs.
The event being used to detect keyboard inputs is UserInputService.InputBegan, and its second parameter is a boolean that states whether or not Roblox already processed the input. Your code should look like this:
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if gameProcessedEvent then
return
end
-- Process input
end)
Where should I add this code? Backpack Toolbar? Or somewhere else?
You need to edit the inventory/hot-bar LocalScript
that contains the UserInputService.InputBegan
event
I added that script right above my toolbar script and it still doesn’t work. If I still type 1 in the chat window, the tool still gets caught.
in this event handler function
not
BackpackModule
– This backpack script doesn’t support hopperbin because using :ToggleActive() will raise an error and its belong to corescript
– Backpack Version 5.1
– OnlyTwentyCharacters, SolarCrane
local UserInputService = game:GetService(“UserInputService”)
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if gameProcessedEvent then
return
end
–Process input
end)
local BackpackScript = {}
BackpackScript.OpenClose = nil – Function to toggle open/close
BackpackScript.IsOpen = false
BackpackScript.StateChanged = Instance.new(“BindableEvent”) – Fires after any open/close, passes IsNowOpen
I added this, but the symptom still remains.