How do i make the players able to move freely again?

What do you want to achieve? Keep it simple and clear!

i was following a thread on the devforum regarding on how to make the player only move sideways using Context Action Service but i want to know how to make it so that the player could move freely again do i use unbind action?

heres the code:

local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
 
local jumping = false
local leftValue, rightValue = 0, 0
 
local function onLeft(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then	
		leftValue = 1
	elseif inputState == Enum.UserInputState.End then
		leftValue = 0
	end
end
 
local function onRight(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then
		rightValue = 1
	elseif inputState == Enum.UserInputState.End then
		rightValue = 0
	end
end
 
local function onJump(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then
		jumping = true
	elseif inputState == Enum.UserInputState.End then
		jumping = false
	end
end
 
local function onUpdate()
	if player.Character and player.Character:FindFirstChild("Humanoid") then
		if jumping then
			player.Character.Humanoid.Jump = true
		end
		local moveDirection = rightValue - leftValue
		player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
	end
end
 
RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
 
ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
ContextActionService:BindAction("Jump", onJump, true, "w", Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)

you dont have to create the full script, you could just explain it cause im confused.

1 Like

BindAction is overriding the movement keys.
I think there might be a way to make it so the default movement keys still work but you might have to use UserInputService otherwise.

i already fix this problem but now theres a bigger problem im going to make another post

1 Like

if anybody want to know i just input the forward backwards movement back

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.