How do I make gun movements in first video?
I tried to detecting if the camera has moved left but it's not smooth.
local lasty = Y
function Rotate()
local CurrentRotation = workspace.CurrentCamera.CFrame
local X,Y,Z = CurrentRotation:ToOrientation()
if Y > lasty then
RotationCF = RotationCF:Lerp(CFrame.Angles(0,math.rad(10),0),.1)
print("moving left")
elseif Y < lasty then
RotationCF = RotationCF:Lerp(CFrame.Angles(0,-math.rad(5),0),.1)
end
lasty = Y
end
Runservice.RenderStepped:Connect(function()
if not framework.viewmodel then return end
if framework.viewmodel and framework.viewmodel:IsDescendantOf(camera) then
framework.viewmodel:SetPrimaryPartCFrame(camera.CFrame * RotationCF)
end
Rotate()
end)
end```