#How to disable player input?

1 messages · Page 1 of 1 (latest)

autumn iris
#

I am trying to disable player input, but none of my methods seem to work. Could somebody tell me an easy and sustainable way to acheive this?

patent oyster
#

local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")

local inputDisabled = false

local function disableControls()
ContextActionService:BindAction("DisableMovement", function() return Enum.ContextActionResult.Sink end, false, unpack(Enum.PlayerActions:GetEnumItems()))
end

UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.E and not inputDisabled then
inputDisabled = true
disableControls()
end
end)

#

Put that in a local script in starterplayerscripts