How do you force player to walk?

I want a player to keep walking forward (as if pressing W) without pressing any keys. How would I do this?

EDIT @slothfulGuy

EDIT 2 It’s important to set second argument of Move(vector3, relative to camera) to true, so the player can turn around freely.

Use T to toggle auto-running.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

local character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local autoRun_on = false
local autoRunning

UIS.InputBegan:Connect(function(input)
	if (input.UserInputType == Enum.UserInputType.Keyboard) then
		if (input.KeyCode == Enum.KeyCode.T) then
			autoRun_on = not autoRun_on
			
			if (autoRun_on) then
				autoRunning = RunService.RenderStepped:Connect(function(dt)
					humanoid:Move(Vector3.new(0,0,-1), true)
				end)
			else autoRunning:Disconnect()
			end		
		end
	end
end)
6 Likes