Make character strafe left/right instead of rotate left and right when pressing A or D

Hey there. I’m trying to make a custom camera for my game, very similar to shift lock mode. I’ve run into an issue, though. When I press the A or D key my character will rotate left and right (respectively), instead of strafing like with shift lock enabled. This is what I mean:

My version:
robloxapp-20200525-2202404.wmv (1.2 MB)

Roblox shift lock (intended functionality):
robloxapp-20200525-2203238.wmv (1.3 MB)

I’ve searched for a solution for this but have not found one. I’ve also looked into action binding and what not but I didn’t find anything relevant to my issue.

Thanks,
K_reex

1 Like

You can have the rotation of the HumanoidRootPart match that of the camera.

local CAMERA = workspace.CurrentCamera;
local UP_VECTOR = Vector3.new(0,1,0);

local hrp = ...;--Define the HumanoidRootPart

game:GetService("RunService").RenderStepped:Connect(function()
    hrp.CFrame = CFrame.fromMatrix(hrp.Position,CAMERA.CFrame.RightVector,UP_VECTOR);
end);
3 Likes