Hi!
I was trying to make a script for a 2D platformer that disables the 'w' and 's' keys, and replaces the action 'w' performs with 'jumpAction'. Here is the code (in a localScript):
local ContextActionService = game:GetService("ContextActionService") local plyr = game:GetService("Players").LocalPlayer local uis = game:GetService("UserInputService") for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do controller:Destroy() end uis.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.W then if plyr.Character:FindFirstChild("Humanoid") then plyr.Character.Humanoid.Jump = true end end end) ContextActionService:UnbindAction("forwardMovement") ContextActionService:UnbindAction("backwardMovement") ContextActionService:UnbindAction("jumpAction")
For some reason, the code only works in the editor, and not the actual game. Can someone explain what I'm doing wrong? Thanks