wait(2)
local player = game.Players.LocalPlayer
local BV = Instance.new("BodyVelocity", player.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local UIP = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
UIP.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.W then
BV.Velocity = camera.CFrame.LookVector*100
elseif Key.KeyCode == Enum.KeyCode.S then
BV.Velocity = camera.CFrame.LookVector*-100
elseif Key.KeyCode == Enum.KeyCode.A then
BV.Velocity = -(camera.CFrame.LookVector * camera.CFrame.Z) --faulty
elseif Key.KeyCode == Enum.KeyCode.D then
BV.Velocity = -(camera.CFrame.LookVector *- camera.CFrame.Z) -- faulty
end
end)
I am trying to make it so when you press A or D you go to the right or left always, taking camera CFrame into count. I got it on W and S but on A and D it just goes one direction no matter where I look. How do I fix this?
If you wanna try this out, put it in playergui and you will see what I mean.

3 comments
It's like so with the W and S too, it only updates when you press it again, I will look if I can make the script better.
that wasnt my question. my question was how do i make the player go right or left when pressed A or D.
Sorry, I don't know how to fix that script, I made a fly tool what you can use, but I couldn't fix the script in the way you want. https://www.roblox.com/library/3397327272/Fly-tool