I need help with my view model movement here for my fps game

I need help in my script for my framework which changes in constant :slight_smile:
i want the final product to be smooth

here is the script btw

local RunService = game:GetService(“RunService”)
local Players = game:GetService(“Players”)

local camera = workspace.CurrentCamera

local speed = 1.2
local intensity = 0.1
local tweenservice = game:GetService(“TweenService”)
local smoothness = 0.3

RunService.RenderStepped:Connect(function()
if camera:FindFirstChild(“Part”) then
local viewmodel = camera:FindFirstChild(“Part”).PrimaryPart
local character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:FindFirstChild(“Humanoid”)

	local t = tick()
	local x = math.cos(t * speed) * intensity
	local y = math.sin(t * speed) * intensity
	local z = -1
	local value = t * script:WaitForChild("Value").Value
	local defaultpos = viewmodel.CFrame

	if  humanoid.MoveDirection.Magnitude >0 then
		viewmodel.CFrame = CFrame.new(math.cos(value) * 0.1, math.abs(math.sin(value)) * 0.1, 0)* viewmodel.CFrame  
		viewmodel.CFrame = viewmodel.CFrame * CFrame.fromOrientation(0,math.cos(value) * 0.01,0)
	else
		viewmodel.CFrame = defaultpos
	end
end

end)