Hi, Tophat here. I’ve been scripting a function for a custom shiftlock (than can be enabled at any time) right now, and I’ve been following a community tutorial that I understand the concept of.
However, the movement of the shiftlock function in action looks quite choppy. I think it is due to the fact that it is basically changing the CFrame of the HumanoidRootPart every frame using RunService. I’ve tried using TweenService to try solve this, but apparently my attempts to do so have ended in no change, if not just becoming significantly buggier and worse. The code is below:
local function ShiftLock(Active)
if Active then --This parameter acts as a toggle.
Humanoid.AutoRotate = false
Tween3:Play() --This is an unrelated tween for FOV changing.
game:GetService("RunService"):BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
Humanoid.RootPart.CFrame = CFrame.new(Humanoid.RootPart.Position) * CFrame.Angles(0,y,0) --Sets HumanoidRootPart's CFrame depending on the rotation of the camera.
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.
end)
else
Tween4:Play() --Anoter unrelated tween.
Humanoid.AutoRotate = true
game:GetService("RunService"):UnbindFromRenderStep("ShiftLock")
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default -- Unbinds and resets all changes, reverting camera to default state.
end
end
I would gladly like some help please, thanks.