How to make custom shift lock with rigid locked movement

I am making a custom shift lock, and it works except for moving left and right.
In default shift lock, the player can move left and right without turning their body. But with my shift lock, the player will spin.

https://gyazo.com/8ee04d27640332cdcb7c2f661a6da5b3

How do I change the character movement so it don’t spin?

I tried looking through a lot of PlayerControl modules and I did not see anything useful

I tried disabling player movement using this method

And then using a VectorForce to move the player but it is too strong when the player jumps and too weak when the player is on the ground

https://gyazo.com/2e0bab23e5912abefb4af484e66f8c19

What should I do? Is there other method to do this?

If you need any of my code pls tell me in the comments!

1 Like

What method are you using for rotating the character?

I was able to get pretty close functionality using the code below.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()

local camera = workspace.CurrentCamera

game:GetService("RunService").RenderStepped:Connect(function()
	local pitch, yaw, roll = camera.CFrame:ToEulerAnglesYXZ()
	character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.CFrame.p) * CFrame.Angles(0,yaw,0)
end)

It doesn’t rotate the camera without pressing right click yet, but seems to simulate the behaviour you want pretty well?.

7 Likes

thx for your post, i solved it! i realised you were setting the humanoid root part’s cframe to a new cframe instead of using its own cframe, which caused the humanoid root part’s rotation to be fixed.

i was doing this

humanoidRootPart.CFrame = humanoidRootPart.CFrame * CFrame.Angles(0, math.rad(-Delta.X) * YAngleSensitivity, 0)

but i changed it to this and it now works perfectly!

humanoidRootPart.CFrame = 
		CFrame.new(rootPosition, rootPosition + (cameraLookVector * Vector3.new(1, 0, 1) * 50))
		* CFrame.Angles(0, math.rad(-Delta.X) * YAngleSensitivity, 0)
1 Like