For my game, I need to temporarily disable a specific key, which is the Z key on the keyboard. What I managed to do is disable the player's control which are the keys WASD & space with this local script.
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")) local Controls = PlayerModule:GetControls() Controls:Disable() Controls:Enable()
But I also want to temporarily disable the Z key. Someone can help me with the Z key please
You can disable certain keys through ContextActionService:
local ContextActionService = game:GetService("ContextActionService") ContextActionService:BindActionAtPriority("DisableZ", function() return Enum.ContextActionResult.Sink end, false, Enum.ContextActionPriority.High.Value, Enum.KeyCode.Z)
You can then enable it back by setting it true:
local ContextActionService = game:GetService("ContextActionService") ContextActionService:BindActionAtPriority("EnableZ", function() return Enum.ContextActionResult.Pass end, true, Enum.ContextActionPriority.High.Value, Enum.KeyCode.Z)