Can't disable player's input

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!

You would have to manually disable them in the script that uses the Shift and Ctrl keys.

1 Like

use booleans to check if sprinting is activated so the player can’t crouch