Viewmodel Script bug

  1. What do you want to achieve? Fix this viewmodel script that makes you visible in LockFirstPerson CameraMode

  2. What is the issue? It does this weird thing when i look down

  3. What solutions have you tried so far? Changing the Humanoid’s CameraOffset (as you can see in the code down below)

Code: (StarterCharacterScripts)

repeat task.wait() until script.Parent:IsA("Model") 
and not game:GetService("Players"):FindFirstChildOfClass("Player").PlayerGui:FindFirstChild("IntroGui")

game:GetService("RunService").RenderStepped:Connect(function()
	script.Parent:FindFirstChild("Humanoid").CameraOffset = Vector3.new(0,0,-.6)
	for _,part in script.Parent:GetChildren() do
		if part:IsA("BasePart") or part:IsA("MeshPart") then
			if part.Name ~= "Head" then
				part.LocalTransparencyModifier = 0
			else
				part.LocalTransparencyModifier = 1
			end
		end
	end
end)

also, there are some scripts that mess with the camera on my game, but i dont think they have anything to do with the bug, here is one for example:

local run = game:GetService'RunService'
local uis = game:GetService'UserInputService'

local cam = workspace.CurrentCamera

local mult = 180/math.pi
local clamp = math.clamp

local current = Vector2.zero
local targetX, targetY = 0, 0

local speed = 4.5 -- Set the speed of the animation
local sensitivity = 0.7 -- Set the sensitivity of the rotation

run:BindToRenderStep("SmoothCam", Enum.RenderPriority.Camera.Value-1, function(dt)
	uis.MouseDeltaSensitivity = 0.01
	
	local delta = uis:GetMouseDelta()*sensitivity*50
	targetX += delta.X
	targetY = clamp(targetY+delta.Y,-90,90)
	current = current:Lerp(Vector2.new(-targetX,-targetY), dt*(speed*5))
	
	cam.CFrame = CFrame.fromOrientation(current.Y/mult,current.X/mult,0)
end)