- What do you want to achieve? Keep it simple and clear!
I would like to unbind/sink movement keys and rebind them for different purposes.
- What is the issue? Include screenshots / videos if possible!
Sinking movement keys works fine, but I am having trouble binding them for different use. The bind is created but it won’t pass to the function.
My code to sink movement function:
local cas = game:GetService("ContextActionService") local function sink() return Enum.ContextActionResult.Sink end ----Sink movement keys cas:BindActionAtPriority( "MovementSink",sink,false, Enum.ContextActionPriority.High.Value, Enum.PlayerActions.CharacterLeft, Enum.PlayerActions.CharacterRight, Enum.PlayerActions.CharacterForward, Enum.PlayerActions.CharacterBackward )
As I said, this works just fine for sinking. However binding w to a different function just doesn’t work.
Here’s my bind code and function code:
-- Function that should be for W local function forward (actionName, InputState) print("1") if actionName == "forward" then if InputState == Enum.UserInputState.Begin then flying = true force.Force = force.Force + (Vector3.new(1,1,1) * camera.CFrame.LookVector.Unit) print(force.Force) elseif InputState == Enum.UserInputState.End then flying = false force.Force = force.Force - Vector3.new(speed,0,0) end end end cas:BindAction("forward",forward,false,Enum.KeyCode.W)
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I can just dial WalkSpeed to 0 and it will work fine as i wont need to sink movement keys, however, I would rather disable movement keys entirely than set them to what I want.
Its worth noting changing the key from W to any other key that I didn’t sink works. Also, the sinking code and the function code are in two different scripts.