Hey everyone! I’m trying to disable player inputs, in order for it to not be able to activate other movement mechanics in my game, such as crouch and sprint.
By looking at some posts on the DevForum I found this script, and adapted it to my game:
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"
ContextActionService:BindAction(
FREEZE_ACTION,
function() return Enum.ContextActionResult.Sink end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
script.Parent.Changed:Connect(function()
if script.Parent.Value == true then
ContextActionService:BindAction(
FREEZE_ACTION,
function() return Enum.ContextActionResult.Sink end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
else
ContextActionService:UnbindAction(FREEZE_ACTION)
end
end)
While it works with the basic movement keys, such as WASD, the player can still trigger sprint and crouch trought Shift and Ctrl keys. How could I fix it?
Thank you in advance!