Hello! So basically what I am doing is creating a third person shooter system however, I need help with one thing.
What I would like to achieve is to disable “Right mouse button” and “X” whenever the player touches a part (which will be put in water and set to transparent)
I have tried multiple scripts and getting pretty desperate, please help me out!
If you use ContextActionService you are easily able to enable (bind) and disable (unbind) keys when you need to.
So your code would look something like this:
local ContextActionService = game:GetService("ContextActionService")
local function enableInput()
ContextActionService:BindAction("RightClick", Function, false, Enum.UserInputType.MouseButton2) -- Right Click | Replace "Function" with the function that the action runs |
ContextActionService:BindAction("X", Function, false, Enum.KeyCode.X ) -- X | Replace "Function" with the function that the action runs |
end
local function disableInput()
ContextActionService:Unbind("RightClick")
ContextActionService:Unbind("X")
end