This script for custom topdown controls doesn't work on the actual game and only works in studio In the actual game the only control that works is jump.
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
local ContextActionService = game:GetService('ContextActionService')
local leftValue, rightValue, forwardValue, backwardValue = 0, 0, 0, 0
local function onLeft(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
leftValue = 1
else if inputState == Enum.UserInputState.End then
leftValue = 0
end
end
end
local function onRight(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
rightValue = 1
else if inputState == Enum.UserInputState.End then
rightValue = 0
end
end
end
local function onForward(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
forwardValue = 1
else if inputState == Enum.UserInputState.End then
forwardValue = 0
end
end
end
local function onBackward(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
backwardValue = 1
else if inputState == Enum.UserInputState.End then
backwardValue = 0
end
end
end
local function onUpdate()
if player.Character and player.Character:FindFirstChild('Humanoid') then
local moveDirection = rightValue - leftValue
local moveDirection2 = backwardValue - forwardValue
player.Character.Humanoid:Move(Vector3.new(moveDirection,0,moveDirection2), false)
end
end
RunService:BindToRenderStep('Control', Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction('Forward', onForward, true, 'w', Enum.KeyCode.Up, Enum.KeyCode.DPadUp)
ContextActionService:BindAction('Backward', onBackward, true, 's', Enum.KeyCode.Down, Enum.KeyCode.DPadDown)
ContextActionService:BindAction('Left', onLeft, true, 'a', Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
ContextActionService:BindAction('Right', onRight, true, 'd', Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
