#camera rotates very fast while aiming gun without doing anything

1 messages · Page 1 of 1 (latest)

forest viper
#

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)``

#

camera rotates very fast while aiming gun without doing anything

scenic tinsel
#

Can you show a video?

forest viper
#

when i get home imma send video

forest viper
scenic tinsel
#

Riight

#

Its gotta have smth to do with this for sure

run.RenderStepped:Connect(function()
    if isaiming then
        cam.CFrame = aimcam.CFrame * plr.Character.Head.CFrame:toObjectSpace(plr.Character.Head.CFrame)
    end
end)
#

Why do you need a part to use as the cam's pos

#

When you can very easely just change the cam's zoom

#

Or Field of View

forest viper
#

the point of the function is to aim down the sight of the weapon

scenic tinsel
#

Well k but you don't have to force the players head to do it

#

Zoom and FoV are just enough to make a aiming system

#

Then if you really want to move the head just do it on the server

forest viper
#

but how will i manage to position it perfectly alligned with the sight?

#

i mean i cant just zoom the camera in like in cs 1.6

scenic tinsel
#

k fair point

forest saffron
#

I have the same problem crying

scenic tinsel
#

bro...

#

this shit is from last year

#

and im not even the guy who's struggling

forest saffron