- What do you want to achieve? Keep it simple and clear!
I want to temporarily turn of user input or at least selected keycodes, but on turning it back on it will take in the input before the turn off or during the turn off. - What is the issue? Include screenshots / videos if possible!
I am not sure how to achieve turning off input then checking what input is being pressed during or before the turn off effectively. - What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried contextActionService but it only achieves one of two things which is turning off input but turning input back on it, does not register BEFORE or DURING keys being pressed until I apply input AFTER I turn user input back on.
I am trying to make a combat system so I am wanting the character to be in states like stunned (so they can’t walk away or attack back ) or in attacking (so they can’t jump).
Best game examples is battlegrounds games basically.
My Module script for turning on and off input for ContextActionService (but I made this like 5 months ago because I could not solve the problem I am asking to solve in this post).
local ContextActionService = game:GetService("ContextActionService")
local Input = {}
function Input.disableUI(Name,Function,inputobject)
return Enum.ContextActionResult.Sink --and print("denied input")
end
function Input.Disable_Now()
ContextActionService:BindAction("disablednow",Input.disableUI,false,Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D, Enum.KeyCode.Space,Enum.KeyCode.One,Enum.KeyCode.Two,Enum.KeyCode.Four)
--print("disabled now")
end
function Input.Enable_Now()
ContextActionService:UnbindAction("disablednow")
--print("enabled now")
end
return Input