A normal walk script

local contextActionService = game:GetService'ContextActionService'

local forwardValue, backwardValue, leftValue, rightValue = 0,0,0,0

local walkDirection = Vector3.new()

contextActionService:BindAction('walkForward', function()

	forwardValue = -1 - forwardValue

	walkDirection = (forwardValue == 0) and Vector3.new(walkDirection.x,0,backwardValue) or Vector3.new(walkDirection.x,0,forwardValue)

end, false, Enum.PlayerActions.CharacterForward)

contextActionService:BindAction('walkBackward', function()

	backwardValue = 1 - backwardValue

	walkDirection = (backwardValue == 0) and Vector3.new(walkDirection.x,0,forwardValue) or Vector3.new(walkDirection.x,0,backwardValue)

end, false, Enum.PlayerActions.CharacterBackward)

contextActionService:BindAction('walkLeft', function()

	leftValue = -1 - leftValue

	walkDirection = (leftValue == 0) and Vector3.new(rightValue,0,walkDirection.z) or Vector3.new(leftValue,0,walkDirection.z)

end, false, Enum.PlayerActions.CharacterLeft)

contextActionService:BindAction('walkRight', function()

	rightValue = 1 - rightValue

	walkDirection = (rightValue == 0) and Vector3.new(leftValue,0,walkDirection.z) or Vector3.new(rightValue,0,walkDirection.z)

end, false, Enum.PlayerActions.CharacterRight)

local runService = game:GetService'RunService'

local player = game:GetService'Players'.LocalPlayer

runService:BindToRenderStep('update player:Move', 100, function()

	player:Move(walkDirection, true)

end)

i wrote this in pocket lua (a script editor)
you cant change the font there and thats why the code is indented every line

1 Like