So i have a shiftlock system when people aim the gun but when they go in shift lock
the camera starts bugging out video is right here
--
local function shiftLock(active)
if active and script.Parent.Parent:FindFirstChild("Humanoid").Health ~= 0 and plr.Character:WaitForChild("Humanoid").Sit ~= true then
plr.Character:WaitForChild("CamSway").Enabled = false
plr.Character:WaitForChild("CamSway_OnMouse").Enabled = false
hum.CameraOffset = Vector3.new( 3, 0, -3)
hum.AutoRotate = true
RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, y , 0)
plr.Character:FindFirstChild("CamSway").Enabled = false
plr.Character:FindFirstChild("CamSway_OnMouse").Enabled = false
print("sway disabled")
end)
-- Lock camera zoom while aiming
if isAiming then
plr.CameraMinZoomDistance = 10
plr.CameraMaxZoomDistance = 10
-- Select animation based on ToggleNewAnim value
local anim
if script.Parent.ToggleNewAnim.Value == false then
anim = game.ReplicatedStorage.Anims.PistolAnims:FindFirstChild("Aim1")
else
anim = game.ReplicatedStorage.Anims.PistolAnims:FindFirstChild("Aim2")
end
-- Play the selected animation if it exists
if anim then
animtrack = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(anim)
animtrack:Play()
HoldAnim:Stop()
else
warn("Animation not found")
end
end
else
hum.CameraOffset = Vector3.new(0, 0, 0) -- Reset offset
RunService:UnbindFromRenderStep("ShiftLock")
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
hum.AutoRotate = true
plr.CameraMinZoomDistance = 0.5
plr.CameraMaxZoomDistance = 15
UserInputService.MouseIconEnabled = true
-- Stop aiming animation if it's playing
if animtrack then
animtrack:Stop()
HoldAnim:Play()
end
end
end