Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to disable player input, even for controllers?

Hello, I'm making a turn-based game that should be compatible for controllers. I've ended up running into a small issue.

Although "ControlModule" works perfectly for keyboards, it doesn't really work well for controllers, as the player can still input using the control stick, which is the complete opposite of what I want. Furthermore, I tried making every KeyCode sink via ContextActionService. It works flawlessly with my keyboard, but again, my gamepad still prevails.

So, my question stands here. How do I disable player input for controllers and keyboards?

3 comments

0

What type of input are you trying to disable?

0

Movement (aka joystick). I'm not going to set WalkSpeed to 0, since some attacks will require walking.

0
  1. Run a game is studio (any game) 2. Swich to server 3. Copy StarerModule in StarterPlayer->StarterPlayerScripts. 4. Stop the game 5. Paste StarterModule back where it was. 6. Find gamepad module within. 7. Have Fun! (just remember that those scripts may be updated over time by roblox, and the ones you copied may not be compatible anymore)

1 answer

You could simply do this

local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"

ContextActionService:BindAction(
    FREEZE_ACTION,
    function() return Enum.ContextActionResult.Sink end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems())
)

and to unfreeze do this

ContextActionService:UnbindAction(FREEZE_ACTION)

2 comments

0

That's what I meant by trying to sink it. It doesn't work at all.

0

Well then just set walk speed and jump power to 0 i guess?

This discussion is preserved as it was. New answers, comments, and votes are closed.