Trouble with AlignOrientation Script

So, I’m adding alight-orientation to make my aiming system smoother, because the aiming system is just making you shift lock.

Now, I have 3 main issues.
1. Once I join my player is back pedaling.
2. My player is floating off the ground
3. And finally when I’m in shiftlock and look in any direction it looks like I’m using the fly command from kohls admin.

I don’t know if it’s the script or just the settings from the align orientation itself, also I’m getting no errors, so I’m assuming it has to do with the settings.

Properties
image
image

script

local TweeningService = game:GetService("TweenService")
local Player = game:GetService("Players").LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)

local Aim = Vector3.new(2.10, 0.70, 0) -- Field of view when shift lock is enabled
local Nim = Vector3.new(0, 0, 0) -- Default field of view

local RootAttachment = Instance.new("Attachment", HumanoidRootPart)

-- Create a new invisible part to hold the CameraAttachment
local CameraPart = Instance.new("Part")
CameraPart.Anchored = true
CameraPart.CanCollide = false
CameraPart.Transparency = 1
CameraPart.Parent = workspace

local CameraAttachment = Instance.new("Attachment", CameraPart)

local AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.Attachment0 = RootAttachment
AlignOrientation.Attachment1 = CameraAttachment
AlignOrientation.Enabled = true
AlignOrientation.Parent = HumanoidRootPart

local function Aimming(enabled)
	_G.ForceShiftLock = enabled
	local fov = enabled and Aim or Nim
	local tweenInfo = TweenInfo.new(0.5) -- Duration of the tween
	local tween = TweeningService:Create(Humanoid, tweenInfo, {CameraOffset = fov})
	tween:Play()
end

local function ShiftLock(Active)
	if Active and Humanoid.CameraOffset == Vector3.new(0, 0, 0) then
		Aimming(true)
		Humanoid.AutoRotate = false -- Disable the automatic rotation since we are the ones setting it.
		AlignOrientation.Enabled = true -- Enable AlignOrientation

		local function ConnectShiftLock()
			local CameraLookVector = workspace.CurrentCamera.CFrame.LookVector
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter -- Set the mouse to center every frame.

			-- Position the CameraPart to follow the camera
			CameraPart.CFrame = workspace.CurrentCamera.CFrame

			-- Update the AlignOrientation CFrame to smoothly follow the camera
			AlignOrientation.CFrame = CFrame.lookAt(Vector3.zero, CameraLookVector * Vector3.new(2.10, 0.70, 0))
		end
		RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, ConnectShiftLock)
	else
		Aimming(false) -- Move the camera back to normal.
		RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
		Humanoid.AutoRotate = true -- Let the humanoid handle the camera rotations again.
		AlignOrientation.Enabled = false -- Disable AlignOrientation
	end
end

wait(5)
ShiftLock(true)
wait(5)
ShiftLock(false)
wait(2)
ShiftLock(true)
wait(2)
ShiftLock(false)```

I had the same issue, but I fixed it through anchoring the HRP. But obviously you wouldn’t want that, so just make the HRP massless.

If that doesn’t work try turning cancollide off for the HRP aswell I guess.

1 Like

Yeah, I followed your instructions, but my startercharacter is still floating off the ground and the flying thing. I just don’t know what I’m doing wrong atp

Maybe try messing around with network ownership, I think that helped for me too.

1 Like

You can try also messing with setstateenabled, what I did for my flying script was disable freefalling.

And some other ones like fallingdown or getting up.

1 Like

What worked? The state enabled changes or?

Na, I just decided not to use align orientation, just remade the script using lerp, and your idea of stateenabled

Yeah alignorientation/bodygyros are basically useless and they’re harder to use.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.