i made it so that when you press right mouse button the cameras CFrame is set to a parts CFrame, but the only problem is that when i press right click the camera rotates extremely fast without me even touching the mouse. (also for some reason, if i try in 3rd person it works just fine except i cant move the camera)
my script:
``local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local cam = workspace.CurrentCamera
local mosin = plr.Character["Right Arm"].MosinNagant
local run = game:GetService("RunService")
local head = plr.Character["Head"]
local humanoidRootPart = plr.Character:WaitForChild("HumanoidRootPart")
local shot = mosin.shot
local aimcam = mosin.aimcam
local isaiming = false
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isaiming = true
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
cam.CameraType = Enum.CameraType.Scriptable
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isaiming = false
uis.MouseBehavior = Enum.MouseBehavior.Default
cam.CameraType = Enum.CameraType.Custom
end
end)
run.RenderStepped:Connect(function()
if isaiming then
cam.CFrame = aimcam.CFrame * plr.Character.Head.CFrame:toObjectSpace(plr.Character.Head.CFrame)
end
end)``
