I am making a top down game similar to snake and I want the player to keep walking even if they aren't holding w or dragging their cursor on mobile. The player would be able to turn 90 degrees by pressing a or d. I have made the player move without holding w or dragging their cursor on mobile but they can not turn by 90 degrees by pressing a or d. The camera is also a part that is in the sky rotated towards the baseplate. When they press a or d it just makes them turn for a millisecond then stop, here's how it looks like: https://gyazo.com/d3faaf808703454f65fa1ff8d6a7ba24
I put this in StarterPlayerScripts
local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
Controls:Disable()
I put this in StarterPlayerScripts
game.Players.LocalPlayer:Move(Vector3.new(0, 0, 1), true)
local UIS = game:GetService("UserInputService")
local function GetHrp()
return game:GetService("Players").LocalPlayer.Character.HumanoidRootPart or game:GetService("Players").LocalPlayer.Character:FindFirstChildOfClass("Humanoid").RootPart
end
UIS.InputBegan:Connect(function(UserInputType)
if UserInputType.KeyCode == Enum.KeyCode.A then
GetHrp().CFrame = GetHrp().CFrame * CFrame.Angles(0,math.rad(90),0)
elseif UserInputType.KeyCode == Enum.KeyCode.D then
GetHrp().CFrame = GetHrp().CFrame * CFrame.Angles(0,math.rad(-90),0)
end
end)

6 comments
I suggest you look at: https://developer.roblox.com/en-us/api-reference/class/UserInputService
And also looping.
@radiant_Light203 I know how to detect hotkeys using UIS but I don't know how to turn a character 90 degrees
Just use orientation when someone presses a or d
@epicnmac They will still be moving foward but just facing a different direction
you keep making the player move forward with vector3 which doesn't care if its character front, u should move him with cframe or something (i think)