Hello,
I’m trying to disable the “a”, “s”, and “d” keys, but it doesn’t seem to do any thing. How can I fix this?
What I currently have:
local ContextActionService = game:GetService("ContextActionService")
ContextActionService:UnbindAction("disableBackwardAction")
ContextActionService:UnbindAction("disableRightAction")
ContextActionService:UnbindAction("disableLeftAction")
Thank you in advance
DargoA
(DargoA)
November 2, 2021, 1:07am
#2
I think that the action name is “moveBackwardAction”, “moveRightAction”, and “moveLeftAction”. You should take a look at this post:
i don’t think the current core scripts use those names anymore in the first place but even if it did… The reason putting your local script in the Replicated First doesn’t work is because, well, anything in the replicated storage replicates first before the character scripts are loaded, and before any movement keys are binded, meaning that unbinding before a bind actually exists won’t do anything. You could yield and wait for everything to load and what not, but i’d argue the replicated first s…
After changing it to move and checking the article the only thing I really changed was changing it to “move”, but it still doesn’t function as intended.
colbert2677
(ImagineerColbert)
November 2, 2021, 1:54am
#4
Sounds like you have a case of your script executing before these actions are bound. The context actions for player movement are bound developer-side. Consider picking a more appropriate moment in your gameplay to unbind these actions such as when gameplay actually begins or after a little bit.
Okay, I added a wait and it still seems to not be working. What should I do? I never done this before and have no clue on what to do.
DesertusX
(Worrywort)
November 2, 2021, 2:22am
#6
Can you share your code as of now?
Sure it’s same thing just with a wait before it
local ContextActionService = game:GetService("ContextActionService")
wait(5)
ContextActionService:UnbindAction("moveBackwardAction")
ContextActionService:UnbindAction("moveRightAction")
ContextActionService:UnbindAction("moveLeftAction")
DesertusX
(Worrywort)
November 2, 2021, 2:24am
#8
While testing the script, have you waited for 5 seconds before trying to move?
Yes I have and I still can move normally.
DesertusX
(Worrywort)
November 2, 2021, 2:27am
#10
Are you receiving any errors in the output?
No I don’t and I tried prints too. Nothing.
DesertusX
(Worrywort)
November 2, 2021, 2:33am
#12
local ContextActionService = game:GetService("ContextActionService")
require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
ContextActionService:UnbindAction("moveBackwardAction")
ContextActionService:UnbindAction("moveRightAction")
ContextActionService:UnbindAction("moveLeftAction")
This makes sure that the keys are binded before unbinding them. By the way, is this in a LocalScript?
1 Like
Yes it is would this be a problem?
DesertusX
(Worrywort)
November 2, 2021, 2:38am
#14
No, it should be in one. Try the code I gave above.
I’ll try as soon as I can I need to do something.